10 /* FIXME: This is cheesy, it should be fixed later */
12 void *realloc(void *ptr
, size_t size
)
14 struct free_arena_header
*ah
;
26 /* Add the obligatory arena header, and round up */
27 size
= (size
+2*sizeof(struct arena_header
)-1) & ARENA_SIZE_MASK
;
29 ah
= (struct free_arena_header
*)
30 ((struct arena_header
*)ptr
- 1);
32 if ( ah
->a
.size
>= size
&& size
>= (ah
->a
.size
>> 2) ) {
33 /* This field is a good size already. */
36 /* Make me a new block. This is kind of bogus; we should
37 be checking the adjacent blocks to see if we can do an
38 in-place adjustment... fix that later. */
40 oldsize
= ah
->a
.size
- sizeof(struct arena_header
);
42 newptr
= malloc(size
);
43 memcpy(newptr
, ptr
, (size
< oldsize
) ? size
: oldsize
);