mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[c] Fixed tracking of realloc in unit test suite
This commit is contained in:
parent
e324c05bfa
commit
5a36abf813
@ -25,6 +25,7 @@ void RegisterMemoryLeakDetector()
|
||||
_setDebugMalloc(_kanjimalloc);
|
||||
#endif
|
||||
_setMalloc(_kanjimalloc);
|
||||
_setRealloc(_kanjirealloc);
|
||||
_setFree(_kanjifree);
|
||||
}
|
||||
|
||||
|
||||
@ -169,6 +169,7 @@ void _free (void* ptr);
|
||||
|
||||
void _setMalloc (void* (*_malloc) (size_t size));
|
||||
void _setDebugMalloc (void* (*_malloc) (size_t size, const char* file, int line));
|
||||
void _setRealloc(void* (*_realloc) (void* ptr, size_t size));
|
||||
void _setFree (void (*_free) (void* ptr));
|
||||
|
||||
char* _readFile (const char* path, int* length);
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
static void* (*mallocFunc) (size_t size) = malloc;
|
||||
static void* (*reallocFunc) (void* ptr, size_t size) = realloc;
|
||||
static void* (*debugMallocFunc) (size_t size, const char* file, int line) = NULL;
|
||||
static void (*freeFunc) (void* ptr) = free;
|
||||
|
||||
@ -47,7 +48,7 @@ void* _calloc (size_t num, size_t size, const char* file, int line) {
|
||||
return ptr;
|
||||
}
|
||||
void* _realloc(void* ptr, size_t size) {
|
||||
return realloc(ptr, size);
|
||||
return reallocFunc(ptr, size);
|
||||
}
|
||||
void _free (void* ptr) {
|
||||
freeFunc(ptr);
|
||||
@ -60,6 +61,11 @@ void _setDebugMalloc(void* (*malloc) (size_t size, const char* file, int line))
|
||||
void _setMalloc (void* (*malloc) (size_t size)) {
|
||||
mallocFunc = malloc;
|
||||
}
|
||||
|
||||
void _setRealloc (void* (*realloc) (void* ptr, size_t size)) {
|
||||
reallocFunc = realloc;
|
||||
}
|
||||
|
||||
void _setFree (void (*free) (void* ptr)) {
|
||||
freeFunc = free;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user