[c] Fixed tracking of realloc in unit test suite

This commit is contained in:
badlogic 2017-05-18 13:42:54 +02:00
parent e324c05bfa
commit 5a36abf813
3 changed files with 9 additions and 1 deletions

View File

@ -25,6 +25,7 @@ void RegisterMemoryLeakDetector()
_setDebugMalloc(_kanjimalloc);
#endif
_setMalloc(_kanjimalloc);
_setRealloc(_kanjirealloc);
_setFree(_kanjifree);
}

View File

@ -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);

View File

@ -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;
}