fix dependency check logic cause config always disabled
[lunaix-os.git] / lunaix-os / tests / units / stubs / valloc.c
index 0d0292206be1858416f413f4654648bdf9e2e6f5..c8897e2405a1b3b7a144bc8e04d7d272c54b01e2 100644 (file)
@@ -1,56 +1,85 @@
 #include <lunaix/mm/valloc.h>
+#include <testing/memchk.h>
 #include <stddef.h>
 
 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