Closed loggerhead closed 8 years ago
The old memory should freed in tgc_realloc because:
tgc_realloc
For realloc(), the input pointer is still valid if reallocation failed.
void *qtr = realloc(ptr, size); if (qtr == NULL) { // free(ptr); tgc_rem(gc, ptr); return qtr; }
I think it should be up to the caller of tgc_realloc to free the old pointer. Essentially tgc_realloc should match the semantics of realloc.
realloc
Oh, I don't consider this point, you are right 😄
The old memory should freed in
tgc_realloc
because: