rem: } if (nptr==NULL) { printf("Could not do realloc"); return NULL;
add: if (nptr==NULL) { wwarning("realloc() failed. Retrying after 2s."); sleep(2); #ifdef TEST_WITH_GC nptr = GC_realloc(ptr, newsize); #else nptr = realloc(ptr, newsize); #endif if (nptr == NULL) { if (Aborting) { fputs("Really Bad Error: recursive realloc() failure.", stderr); exit(-1); } else { wfatal("virtual memory exhausted"); Aborting=1; wAbort(False); } } }
context: void *wrealloc(void *ptr, size_t newsize){    void *nptr;    if (!ptr) {#ifdef TEST_WITH_GC	nptr = GC_malloc(newsize);#else	nptr = malloc(newsize);#endif    } else {#ifdef TEST_WITH_GC	nptr = GC_realloc(ptr, newsize);#else	nptr=realloc(ptr, newsize);#endif    }    if (nptr==NULL) {	printf("Could not do realloc");	return NULL;    }    return nptr;}