LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Fixed-size object allocator. Returned memory is not zeroed. | 5 // Fixed-size object allocator. Returned memory is not zeroed. |
6 // | 6 // |
7 // See malloc.h for overview. | 7 // See malloc.h for overview. |
8 | 8 |
9 #include "runtime.h" | 9 #include "runtime.h" |
10 #include "arch.h" | 10 #include "arch_GOARCH.h" |
11 #include "malloc.h" | 11 #include "malloc.h" |
12 | 12 |
13 // Initialize f to allocate objects of the given size, | 13 // Initialize f to allocate objects of the given size, |
14 // using the allocator to obtain chunks of memory. | 14 // using the allocator to obtain chunks of memory. |
15 void | 15 void |
16 runtime·FixAlloc_Init(FixAlloc *f, uintptr size, void *(*alloc)(uintptr), void (
*first)(void*, byte*), void *arg) | 16 runtime·FixAlloc_Init(FixAlloc *f, uintptr size, void *(*alloc)(uintptr), void (
*first)(void*, byte*), void *arg) |
17 { | 17 { |
18 f->size = size; | 18 f->size = size; |
19 f->alloc = alloc; | 19 f->alloc = alloc; |
20 f->first = first; | 20 f->first = first; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 | 55 |
56 void | 56 void |
57 runtime·FixAlloc_Free(FixAlloc *f, void *p) | 57 runtime·FixAlloc_Free(FixAlloc *f, void *p) |
58 { | 58 { |
59 f->inuse -= f->size; | 59 f->inuse -= f->size; |
60 *(void**)p = f->list; | 60 *(void**)p = f->list; |
61 f->list = p; | 61 f->list = p; |
62 } | 62 } |
63 | 63 |
LEFT | RIGHT |