| // Copyright 2009 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // Fixed-size object allocator. Returned memory is not zeroed. |
| // See malloc.h for overview. |
| // Initialize f to allocate objects of the given size, |
| // using the allocator to obtain chunks of memory. |
| FixAlloc_Init(FixAlloc *f, uintptr size, void *(*alloc)(uintptr), void (*first)(void*, byte*), void *arg) |
| FixAlloc_Alloc(FixAlloc *f) |
| f->list = *(void**)f->list; |
| if(f->nchunk < f->size) { |
| f->chunk = f->alloc(FixAllocChunk); |
| throw("out of memory (FixAlloc)"); |
| f->nchunk = FixAllocChunk; |
| FixAlloc_Free(FixAlloc *f, void *p) |