From 3b836d665f469a05a64df7672065d3357dffe7d9 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 1 Aug 2002 07:45:47 +0000 Subject: (HEAP_MIN_SIZE): New macro. (HEAP_MIN_FREE_AREA_SIZE): Increase size. Enable debugging if HEAP_DEBUGGING is defined. --- libc/stdlib/malloc/heap.h | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'libc/stdlib') diff --git a/libc/stdlib/malloc/heap.h b/libc/stdlib/malloc/heap.h index 445b012ce..38451f091 100644 --- a/libc/stdlib/malloc/heap.h +++ b/libc/stdlib/malloc/heap.h @@ -52,16 +52,25 @@ struct heap_free_area #define HEAP_ADJUST_SIZE(sz) \ (((sz) + HEAP_GRANULARITY - 1) & ~(HEAP_GRANULARITY - 1)) -/* The minimum size of a free area. It must include at least enough room - to hold a struct heap_free_area, plus enough extra to be usefully - allocated. */ + +/* The minimum allocatable size. */ +#define HEAP_MIN_SIZE HEAP_ADJUST_SIZE (sizeof (struct heap_free_area)) + +/* The minimum size of a free area; if allocating memory from a free-area + would make the free-area smaller than this, the allocation is simply + given the whole free-area instead. It must include at least enough room + to hold a struct heap_free_area, plus some extra to avoid excessive heap + fragmentation (thus increasing speed). This is only a heuristic -- it's + possible for smaller free-areas than this to exist (say, by realloc + returning the tail-end of a previous allocation), but __heap_alloc will + try to get rid of them when possible. */ #define HEAP_MIN_FREE_AREA_SIZE \ - (sizeof (struct heap_free_area) + HEAP_ADJUST_SIZE (1)) + HEAP_ADJUST_SIZE (sizeof (struct heap_free_area) + 32) -/* Change this to `#if 1' to cause the heap routines to emit debugging info +/* Define HEAP_DEBUGGING to cause the heap routines to emit debugging info to stderr. */ -#if 0 +#ifdef HEAP_DEBUGGING #include static void HEAP_DEBUG (struct heap *heap, const char *str) { -- cgit v1.2.3