aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2015-10-06 15:37:53 -0400
committerKevin O'Connor <kevin@koconnor.net>2015-10-15 10:52:13 -0400
commit3c6ae7c1ee97460d9f0f7ef07b97d793c385d29d (patch)
tree3132e98d8e8560b773b407ab471ef10fa819ae23
parent7af8d120fba60669843726fed9b470e4ea6ac05e (diff)
downloadseabios-3c6ae7c1ee97460d9f0f7ef07b97d793c385d29d.zip
seabios-3c6ae7c1ee97460d9f0f7ef07b97d793c385d29d.tar.gz
seabios-3c6ae7c1ee97460d9f0f7ef07b97d793c385d29d.tar.bz2
malloc: Add warning if free() called on invalid memory
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/malloc.c10
-rw-r--r--src/malloc.h4
2 files changed, 11 insertions, 3 deletions
diff --git a/src/malloc.c b/src/malloc.c
index c41a0cb..f5c2ed4 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -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)
diff --git a/src/malloc.h b/src/malloc.h
index 2bcb5bf..b765bc4 100644
--- a/src/malloc.h
+++ b/src/malloc.h
@@ -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