X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=ancient_c.c;h=58735d092eaa363ee84678c1a48acfa1783a529d;hb=refs%2Fheads%2Fmaster;hp=46f176941e57752c48c5e2f5c4c1ad9b1ab55187;hpb=11c66cbe2c13bd7a392669f9abb65e82a000eb20;p=ocaml-ancient.git diff --git a/ancient_c.c b/ancient_c.c index 46f1769..58735d0 100644 --- a/ancient_c.c +++ b/ancient_c.c @@ -1,5 +1,4 @@ /* Mark objects as 'ancient' so they are taken out of the OCaml heap. - * $Id: ancient_c.c,v 1.11 2006-10-31 14:39:50 rich Exp $ */ #include @@ -134,13 +133,15 @@ area_init_custom (area *a, static inline int area_append (area *a, const void *obj, size_t size) { + void *ptr; while (a->n + size > a->size) { if (a->size == 0) a->size = 256; else a->size <<= 1; - a->ptr = + ptr = a->realloc ? a->realloc (a->data, a->ptr, a->size) : realloc (a->ptr, a->size); - if (a->ptr == 0) return -1; // Out of memory. + if (ptr == 0) return -1; // Out of memory. + a->ptr = ptr; } memcpy (a->ptr + a->n, obj, size); a->n += size;