aboutsummaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/malloc.h33
1 files changed, 33 insertions, 0 deletions
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 <stddef.h>
+
+/** @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