1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Fixed-size object allocator. Returned memory is not zeroed.
7 // See malloc.h for overview.
13 // Initialize f to allocate objects of the given size,
14 // using the allocator to obtain chunks of memory.
16 runtime_FixAlloc_Init(FixAlloc
*f
, uintptr size
, void *(*alloc
)(uintptr
), void (*first
)(void*, byte
*), void *arg
)
30 runtime_FixAlloc_Alloc(FixAlloc
*f
)
35 runtime_printf("runtime: use of FixAlloc_Alloc before FixAlloc_Init\n");
36 runtime_throw("runtime: internal error");
41 f
->list
= *(void**)f
->list
;
45 if(f
->nchunk
< f
->size
) {
46 f
->sys
+= FixAllocChunk
;
47 f
->chunk
= f
->alloc(FixAllocChunk
);
49 runtime_throw("out of memory (FixAlloc)");
50 f
->nchunk
= FixAllocChunk
;
62 runtime_FixAlloc_Free(FixAlloc
*f
, void *p
)