summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc
diff options
context:
space:
mode:
authorMiles Bader <miles@lsi.nec.co.jp>2002-07-31 02:09:37 +0000
committerMiles Bader <miles@lsi.nec.co.jp>2002-07-31 02:09:37 +0000
commit4d7b95f7d2ddf5f4901a871178c59b55ab042551 (patch)
tree8ccb0d5678291579863a445a47135847521d4379 /libc/stdlib/malloc
parent2fbc5f2c9c7eb68af76c745d19817f78200df410 (diff)
(MALLOC_HEADER_SIZE): New macro.
(MALLOC_BASE, MALLOC_ADDR): Use it.
Diffstat (limited to 'libc/stdlib/malloc')
-rw-r--r--libc/stdlib/malloc/malloc.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/libc/stdlib/malloc/malloc.h b/libc/stdlib/malloc/malloc.h
index 8abc9ed4f..193dabd64 100644
--- a/libc/stdlib/malloc/malloc.h
+++ b/libc/stdlib/malloc/malloc.h
@@ -52,17 +52,21 @@
^ ADDR - MALLOC_ALIGN
*/
+/* The amount of extra space used by the malloc header. */
+#define MALLOC_HEADER_SIZE MALLOC_ALIGNMENT
+
/* Return base-address of a malloc allocation, given the user address. */
-#define MALLOC_BASE(addr) ((void *)((char *)addr - MALLOC_ALIGNMENT))
+#define MALLOC_BASE(addr) ((void *)((char *)addr - MALLOC_HEADER_SIZE))
/* Return the size of a malloc allocation, given the user address. */
#define MALLOC_SIZE(addr) (*(size_t *)MALLOC_BASE(addr))
/* Sets the size of a malloc allocation, given the user address. */
#define MALLOC_SET_SIZE(addr, size) (*(size_t *)MALLOC_BASE(addr) = (size))
/* Return the user address of a malloc allocation, given the base address. */
-#define MALLOC_ADDR(base) ((void *)((char *)base + MALLOC_ALIGNMENT))
+#define MALLOC_ADDR(base) ((void *)((char *)base + MALLOC_HEADER_SIZE))
+/* Locking for multithreaded apps. */
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>