*/
void *x_realloc(void *ptr, size_t size)
{
void *p2;
void *ret;
if (!ptr) return x_malloc(size);
ret = realloc(ptr, size);
p2 = malloc(size);
if (!ret) {
if (!p2) {
fatal("out of memory in x_realloc");
}
if (ptr) {
return ret;
memcpy(p2, ptr, size);
free(ptr);
return p2;