From 9f726c2c8ba98d55935acc1143d2b792ca74e303 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 28 Jan 2009 15:22:16 -0800 Subject: Use explicit allspan list instead of trying to find all the places where spans might be recorded. Free can cascade into complicated span manipulations that move them from list to list; the old code had the possibility of accidentally processing a span twice or jumping to a different list, causing an infinite loop. R=r DELTA=70 (28 added, 25 deleted, 17 changed) OCL=23704 CL=23710 --- src/runtime/mfixalloc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/runtime/mfixalloc.c') diff --git a/src/runtime/mfixalloc.c b/src/runtime/mfixalloc.c index 904ca7e2af..dd4f3f2518 100644 --- a/src/runtime/mfixalloc.c +++ b/src/runtime/mfixalloc.c @@ -12,10 +12,12 @@ // Initialize f to allocate objects of the given size, // using the allocator to obtain chunks of memory. void -FixAlloc_Init(FixAlloc *f, uintptr size, void *(*alloc)(uintptr)) +FixAlloc_Init(FixAlloc *f, uintptr size, void *(*alloc)(uintptr), void (*first)(void*, byte*), void *arg) { f->size = size; f->alloc = alloc; + f->first = first; + f->arg = arg; f->list = nil; f->chunk = nil; f->nchunk = 0; @@ -38,6 +40,8 @@ FixAlloc_Alloc(FixAlloc *f) f->nchunk = FixAllocChunk; } v = f->chunk; + if(f->first) + f->first(f->arg, v); f->chunk += f->size; f->nchunk -= f->size; return v; -- cgit v1.3-5-g9baa