News for hackers. Stuff that matters.
Re:Once upon a time, memory allocators made sense by antirez on Tuesday January 19, 2016 @03:37AM (#10929393)
What I mean is that, when you say:

> Unfortunately, some people are not sane, and have decided that it's equally valid for realloc(p, 0) to return NULL meaning-failure and not free p.

What you want is the following semantics:

    char *my_old_vector = ... ; /* We created / allocated in some way. */
    add_important_stuff_to(my_old_vector);

    char *new_vector = realloc(my_old_vector,size+100);
    if (new_vector == NULL) {
       /* I still have the old vector and can recover. */
    }

There are no comments on this comment yet.