diff options
author | Miles Bader <miles@lsi.nec.co.jp> | 2002-08-19 08:43:30 +0000 |
---|---|---|
committer | Miles Bader <miles@lsi.nec.co.jp> | 2002-08-19 08:43:30 +0000 |
commit | 5a0af72d6d41ad1c8e858b3920a97f070c2a5d8d (patch) | |
tree | 05f9761add6d3e0d003b149c313adacbbf155215 /libc/stdlib | |
parent | 175f6f670de99b6aa0e866df24a792444586ff0d (diff) |
(MALLOC_SETUP): New macro.
(MALLOC_SET_SIZE): Take the base-address of the block, not the user-address.
(MALLOC_ADDR): Macro removed.
Diffstat (limited to 'libc/stdlib')
-rw-r--r-- | libc/stdlib/malloc/malloc.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libc/stdlib/malloc/malloc.h b/libc/stdlib/malloc/malloc.h index 6c4590894..4914a9edc 100644 --- a/libc/stdlib/malloc/malloc.h +++ b/libc/stdlib/malloc/malloc.h @@ -61,15 +61,16 @@ /* The amount of extra space used by the malloc header. */ #define MALLOC_HEADER_SIZE MALLOC_ALIGNMENT +/* Set up the malloc header, and return the user address of a malloc block. */ +#define MALLOC_SETUP(base, size) \ + (MALLOC_SET_SIZE (base, size), (void *)((char *)base + MALLOC_HEADER_SIZE)) +/* Set the size of a malloc allocation, given the base address. */ +#define MALLOC_SET_SIZE(base, size) (*(size_t *)(base) = (size)) + /* Return base-address of a malloc allocation, given the user address. */ #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_HEADER_SIZE)) /* Locking for multithreaded apps. */ |