aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-02-22 12:31:46 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-02-22 12:42:48 +0100
commit29b8c1556bf456596c6c067d413b65b51e17724e (patch)
treeb225381d762af049e9174cdf1459db1f91c9589a /src
downloadmalloc-29b8c1556bf456596c6c067d413b65b51e17724e.tar.gz
malloc-29b8c1556bf456596c6c067d413b65b51e17724e.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/free.c14
-rw-r--r--src/malloc.c15
-rw-r--r--src/realloc.c16
3 files changed, 45 insertions, 0 deletions
diff --git a/src/free.c b/src/free.c
new file mode 100644
index 0000000..22c3faa
--- /dev/null
+++ b/src/free.c
@@ -0,0 +1,14 @@
+/**
+ * @file free.c
+ * @brief Stub implementation of free.
+ */
+
+#include "libft.h"
+#include "malloc.h"
+
+void
+free (void *ptr)
+{
+ (void)ptr;
+ ft_putendl_fd ("FREE", 1);
+}
diff --git a/src/malloc.c b/src/malloc.c
new file mode 100644
index 0000000..8982de0
--- /dev/null
+++ b/src/malloc.c
@@ -0,0 +1,15 @@
+/**
+ * @file malloc.c
+ * @brief Stub implementation of malloc.
+ */
+
+#include "malloc.h"
+#include "libft.h"
+
+void *
+malloc (size_t size)
+{
+ (void)size;
+ ft_putendl_fd ("MALLOC", 1);
+ return (NULL);
+}
diff --git a/src/realloc.c b/src/realloc.c
new file mode 100644
index 0000000..c0bbfed
--- /dev/null
+++ b/src/realloc.c
@@ -0,0 +1,16 @@
+/**
+ * @file realloc.c
+ * @brief Stub implementation of realloc.
+ */
+
+#include "libft.h"
+#include "malloc.h"
+
+void *
+realloc (void *ptr, size_t size)
+{
+ (void)ptr;
+ (void)size;
+ ft_putendl_fd ("REALLOC", 1);
+ return (NULL);
+}