4 typedef unsigned int uint;
13 typedef struct Bucket Bucket;
23 typedef struct Arena Arena;
26 Bucket *btab[MAX2SIZE];
30 #define datoff ((int)((Bucket*)0)->data)
31 #define nil ((void*)0)
33 extern void *sbrk(unsigned long);
42 for(pow = 1; pow < MAX2SIZE; pow++) {
49 /* Allocate off this list */
52 arena.btab[pow] = bp->next;
60 size = sizeof(Bucket)+(1<<pow);
72 arena.btab[pow] = nbp;
74 next = (uint)nbp+size;
75 nbp->next = (Bucket*)next;
101 /* Find the start of the structure */
102 bp = (Bucket*)((uint)ptr - datoff);
104 if(bp->magic != MAGIC)
108 l = &arena.btab[bp->size];
114 realloc(void *ptr, size_t n)
123 /* Find the start of the structure */
124 bp = (Bucket*)((uint)ptr - datoff);
126 if(bp->magic != MAGIC)
129 /* enough space in this bucket */
138 memmove(new, ptr, osize);