Question says it all but here is an example:
typedef struct mutable_t{ int count, max; void **data; } mutable_t; void pushMutable(mutable_t *m, voi
The standard technique is to introduce a new variable to hold the return from realloc. You then only overwrite your input variable if it succeeds:
tmp = realloc(orig, newsize); if (tmp == NULL) { // could not realloc, but orig still valid } else { orig = tmp; }