Skip to content

Commit

Permalink
Revert wasmSpineExtension.cpp, return nullptr if size is zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
dumganhar committed Nov 5, 2024
1 parent 1bcd914 commit c6439cc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions native/cocos/editor-support/spine-wasm/wasmSpineExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,27 @@ char *WasmSpineExtension::_readFile(const String &path, int *length) {
void *WasmSpineExtension::_alloc(size_t size, const char *file, int line) {
SP_UNUSED(file);
SP_UNUSED(line);
if (size == 0) {
return nullptr;
}
return ::malloc(sizeof(uint8_t) * size);
}

void *WasmSpineExtension::_calloc(size_t size, const char *file, int line) {
SP_UNUSED(file);
SP_UNUSED(line);
if (size == 0) {
return nullptr;
}
return ::calloc(1, size);
}

void *WasmSpineExtension::_realloc(void *ptr, size_t size, const char *file, int line) {
SP_UNUSED(file);
SP_UNUSED(line);
if (size == 0) {
return nullptr;
}
return ::realloc(ptr, sizeof(uint8_t) * size);
}

Expand Down

0 comments on commit c6439cc

Please sign in to comment.