X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/9daf4fcdae88f72af60aeb0c7722841af02233d4..HEAD:/lunaix-os/tests/units/stubs/valloc.c diff --git a/lunaix-os/tests/units/stubs/valloc.c b/lunaix-os/tests/units/stubs/valloc.c index 0d02922..c8897e2 100644 --- a/lunaix-os/tests/units/stubs/valloc.c +++ b/lunaix-os/tests/units/stubs/valloc.c @@ -1,56 +1,85 @@ #include +#include #include extern void *malloc(size_t); extern void *calloc(size_t, size_t); extern void free(void*); +static inline void* +_my_malloc(size_t size) +{ + void* ptr; + + ptr = malloc(size); + memchk_log_alloc((unsigned long)ptr, size); + + return ptr; +} + +static inline void* +_my_calloc(size_t size, int n) +{ + void* ptr; + + ptr = calloc(size, n); + memchk_log_alloc((unsigned long)ptr, size * n); + + return ptr; +} + +static inline void +_my_free(void* addr) +{ + memchk_log_free((unsigned long)addr); +} + void* valloc(unsigned int size) { - return malloc(size); + return _my_malloc(size); } void* vzalloc(unsigned int size) { - return calloc(size, 1); + return _my_calloc(size, 1); } void* vcalloc(unsigned int size, unsigned int count) { - return calloc(size, count); + return _my_calloc(size, count); } void vfree(void* ptr) { - free(ptr); + _my_free(ptr); } void vfree_safe(void* ptr) { - if (ptr) free(ptr); + if (ptr) _my_free(ptr); } void* valloc_dma(unsigned int size) { - return malloc(size); + return _my_malloc(size); } void* vzalloc_dma(unsigned int size) { - return calloc(size, 1); + return _my_calloc(size, 1); } void vfree_dma(void* ptr) { - free(ptr); + _my_free(ptr); } void