hi can anyone tell me whats wrong with my realloc
I get segmentationfault when my testprogram does: p = realloc(p, 4711);
thanks for your help!Code:void *realloc(void *oldp, size_t size) { if (oldp == NULL){ return(malloc(size)); } void *newp; size_t oldsize; oldsize = ((Header *)oldp - 1)->s.size * sizeof(Header); newp = malloc(size); if (NULL != newp){ memcpy(newp, oldp, min(size, oldsize)); free((void *)oldp); } return(newp); }