]> xenbits.xensource.com Git - seabios.git/commitdiff
malloc: Add warning if free() called on invalid memory
authorKevin O'Connor <kevin@koconnor.net>
Tue, 6 Oct 2015 19:37:53 +0000 (15:37 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 15 Oct 2015 14:52:13 +0000 (10:52 -0400)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/malloc.c
src/malloc.h

index c41a0cb6cbd797b4d9eacd24b1c9ee945694b066..f5c2ed4d731e484c26ef033498cca8b448997511 100644 (file)
@@ -276,6 +276,16 @@ _free(void *data)
     return 0;
 }
 
+void
+free(void *data)
+{
+    if (!data)
+        return;
+    int ret = _free(data);
+    if (ret)
+        warn_internalerror();
+}
+
 // Find the amount of free space in a given zone.
 u32
 malloc_getspace(struct zone_s *zone)
index 2bcb5bf6dcf37d20c668ca0a773350342dd8e609..b765bc4ad9d1c27226e01f14dd67a20dcffcb1de 100644 (file)
@@ -17,6 +17,7 @@ void malloc_init(void);
 void malloc_prepboot(void);
 void *_malloc(struct zone_s *zone, u32 size, u32 align);
 int _free(void *data);
+void free(void *data);
 u32 malloc_getspace(struct zone_s *zone);
 void malloc_sethandle(void *data, u32 handle);
 void *malloc_findhandle(u32 handle);
@@ -64,8 +65,5 @@ static inline void *memalign_tmp(u32 align, u32 size) {
         return ret;
     return memalign_tmplow(align, size);
 }
-static inline void free(void *data) {
-    _free(data);
-}
 
 #endif // malloc.h