From 29b8c1556bf456596c6c067d413b65b51e17724e Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Sun, 22 Feb 2026 12:31:46 +0100 Subject: Initial scaffold: Makefile, stub malloc/free/realloc, test harness Build system produces libft_malloc_$HOSTTYPE.so shared library with Libft (NOMALLOC=1) as dependency. Stub functions print their name and return NULL. Test runner compares system malloc vs LD_PRELOAD output using write(2) to avoid stdio interference. --- inc/malloc.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 inc/malloc.h (limited to 'inc/malloc.h') diff --git a/inc/malloc.h b/inc/malloc.h new file mode 100644 index 0000000..75ea6e9 --- /dev/null +++ b/inc/malloc.h @@ -0,0 +1,33 @@ +/** + * @file malloc.h + * @brief Public interface for the ft_malloc allocator. + * + * Declares malloc, free, realloc, and show_alloc_mem with the same + * prototypes as their libc counterparts so the library can be used + * as a drop-in replacement via LD_PRELOAD. + */ + +#ifndef MALLOC_H +#define MALLOC_H + +#include + +/** @brief Release the memory block at @p ptr. */ +void free (void *ptr); + +/** @brief Allocate @p size bytes and return a pointer to them. */ +void *malloc (size_t size); + +/** + * @brief Resize the block at @p ptr to @p size bytes. + * @return Pointer to the (possibly moved) block, or NULL on failure. + */ +void *realloc (void *ptr, size_t size); + +/** + * @brief Print every allocated zone and block to stdout, sorted by + * ascending address. + */ +void show_alloc_mem (void); + +#endif -- cgit v1.2.3