From b1a7c10ba575384e8f4ffb6b642783bfbcf51b32 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 27 Apr 2021 17:37:13 +0200 Subject: Better malloc optimizations --- libs/libc/inc/mem.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libs/libc/inc/mem.h') diff --git a/libs/libc/inc/mem.h b/libs/libc/inc/mem.h index de2a84f..63a1b14 100644 --- a/libs/libc/inc/mem.h +++ b/libs/libc/inc/mem.h @@ -5,12 +5,16 @@ #include -void *malloc_debug(u32 size, const char *file, int line, const char *func, const char *inp) NONNULL; +ATTR((malloc)) +ATTR((alloc_size(1))) +RET_NONNULL void *malloc_debug(u32 size, const char *file, int line, const char *func, + const char *inp) NONNULL; +ATTR((malloc)) ATTR((alloc_size(2))) RET_NONNULL void *realloc(void *ptr, u32 size); +ATTR((malloc)) ATTR((alloc_size(1))) RET_NONNULL void *zalloc(u32 size); void free_debug(void *ptr, const char *file, int line, const char *func, const char *inp) NONNULL; + #define malloc(size) malloc_debug((u32)(size), __FILE__, __LINE__, __func__, #size) #define free(ptr) free_debug((void *)(ptr), __FILE__, __LINE__, __func__, #ptr) -void *realloc(void *ptr, u32 size); -void *zalloc(u32 size); #ifdef KERNEL #define STACK_START 0x00500000 // Defined in bootloader -- cgit v1.2.3