From a347ea3787284483158aaa77846ab0b34c017fdb Mon Sep 17 00:00:00 2001 From: Bora Guvendik Date: Mon, 23 Dec 2019 16:44:06 -0800 Subject: lib/malloc: Implement a simple free() only for last malloc() Implement a free() that supports only the last malloc(). Rewind the heap to the last allocation point if the ptr to be freed is matching the end of heap before last malloc(). With current situation, since free() is no-op, every call to malloc() is a memory leak. BUG=b:140124451 TEST=Wrote a test function to do malloc and free operations. Change-Id: I6d43cf54b79e6897cf6882335730b2310e4eae45 Signed-off-by: Bora Guvendik Reviewed-on: https://review.coreboot.org/c/coreboot/+/37919 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/include/stdlib.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/stdlib.h b/src/include/stdlib.h index a8297f82a5..f6369bf0f4 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.h @@ -5,7 +5,6 @@ void *memalign(size_t boundary, size_t size); void *malloc(size_t size); -/* We never free memory */ -static inline void free(void *ptr) {} +void free(void *ptr); #endif /* STDLIB_H */ -- cgit v1.2.3