Author: stepan Date: 2007-10-06 21:06:52 +0200 (Sat, 06 Oct 2007) New Revision: 39
Modified: trunk/filo-0.5/main/malloc.c Log: This patch makes qemu work again on v3. FILO was depending on bss being zero, which is not all that safe in embedded. It's better to zero things you are depending on being zero.
Signed-off-by: Ronald G. Minnich rminnich@gmail.com Acked-by: Stefan Reinauer stepan@coresystems.de
Modified: trunk/filo-0.5/main/malloc.c =================================================================== --- trunk/filo-0.5/main/malloc.c 2007-10-04 06:12:32 UTC (rev 38) +++ trunk/filo-0.5/main/malloc.c 2007-10-06 19:06:52 UTC (rev 39) @@ -43,8 +43,10 @@ static unsigned long total_free, total_alloc; static unsigned int count_free, count_alloc;
+/* FILO should not count on bss being zero. That's dangerous */ static void malloc_init(void) { + memset(&_heap, 0, heap_end - heap_start); head = (struct block_header *) ALIGN(heap_start); head->prev_size = INUSE; head->size = ((heap_end & ~(ALIGNMENT-1)) - ALIGN(heap_start)) @@ -70,9 +72,11 @@ { struct block_header *p, *new_space; unsigned long required, largest, remainder; - - if (!head) + static int firsttime = 1; + if (firsttime) { malloc_init(); + firsttime = 0; + }
#ifdef DEBUG malloc_check();