7 StructAlign = sizeof(union {vlong vl; double d; ulong p; void *v;
8 struct{vlong v;}vs; struct{double d;}ds; struct{ulong p;}ss; struct{void *v;}xs;})
19 ulong total; /* total bytes allocated in can->next */
22 uintptr v; /* last value allocated */
27 * allocator which allows an entire set to be freed at one time
30 mkbin(Bin *bin, ulong size)
34 size = ((size << 1) + (BinSize - 1)) & ~(BinSize - 1);
35 b = malloc(sizeof(Bin) + size - BinSize);
41 b->total = bin->total + bin->pos - (uintptr)bin->body;
42 b->pos = (uintptr)b->body;
43 b->end = b->pos + size;
48 binalloc(Bin **bin, ulong size, int zero)
63 p = (p + (StructAlign - 1)) & ~(StructAlign - 1);
64 if(p + size > b->end){
74 memset((void*)p, 0, size);
79 bingrow(Bin **bin, void *op, ulong osize, ulong size, int zero)
87 if(b != nil && p == b->v && p + size <= b->end){
90 memset((char*)p + osize, 0, size - osize);
93 np = binalloc(bin, size, zero);
96 memmove(np, op, osize);
108 last->pos = (uintptr)last->body;