summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@lsi.nec.co.jp>2002-07-30 09:22:51 +0000
committerMiles Bader <miles@lsi.nec.co.jp>2002-07-30 09:22:51 +0000
commita3483a6eb0bdf7110add4bcb7f4eb6cbd49d0608 (patch)
treeeb0e84b1fb3309877a695efc2ad30b8d2b7dcbba
parentae96781efd37c63dda16175258480d9ad5919418 (diff)
Use new malloc header macros.
-rw-r--r--libc/stdlib/malloc/free.c4
-rw-r--r--libc/stdlib/malloc/malloc.c7
2 files changed, 6 insertions, 5 deletions
diff --git a/libc/stdlib/malloc/free.c b/libc/stdlib/malloc/free.c
index 6de5237dc..657604124 100644
--- a/libc/stdlib/malloc/free.c
+++ b/libc/stdlib/malloc/free.c
@@ -28,8 +28,8 @@ free (void *mem)
struct heap_free_area *fa;
struct heap *heap = &__malloc_heap;
- mem -= MALLOC_ALIGNMENT;
- size = *(size_t *)mem;
+ size = MALLOC_SIZE (mem);
+ mem = MALLOC_BASE (mem);
MALLOC_DEBUG ("free: 0x%lx (base = 0x%lx, total_size = %d)\n",
(long)mem + MALLOC_ALIGNMENT, (long)mem, size);
diff --git a/libc/stdlib/malloc/malloc.c b/libc/stdlib/malloc/malloc.c
index bb1e07dfb..caf90ef02 100644
--- a/libc/stdlib/malloc/malloc.c
+++ b/libc/stdlib/malloc/malloc.c
@@ -119,10 +119,11 @@ malloc (size_t size)
__malloc_unlock ();
if (mem)
- /* Record the size of this block just before the returned address. */
+ /* Record the size of this block. */
{
- *(size_t *)mem = size;
- mem += MALLOC_ALIGNMENT;
+ MALLOC_SET_SIZE (mem, size);
+
+ mem = MALLOC_ADDR (mem);
MALLOC_DEBUG (" malloc: returning 0x%lx (base:0x%lx, total_size:%d)\n",
(long)mem, (long)mem - MALLOC_ALIGNMENT, size);