aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/malloc.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/malloc.c b/src/malloc.c
index f7a2e95..e09cc85 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -307,3 +307,18 @@ void* aligned_alloc(size_t boundary, size_t size)
return memalign(boundary, size);
}
+
+/**
+ * This function returns the allocation size of
+ * a memory segment.
+ *
+ * `p = malloc(n), malloc_usable_size(p)` will return `n`.
+ *
+ * @param segment The memory segment.
+ * @return The size of the memory segment, 0 if `segment` is `NULL`.
+ */
+size_t malloc_usable_size(void* segment)
+{
+ return allocsize(segment);
+}
+