boilerplate: Add xrealloc function

This commit is contained in:
Carl Worth 2006-11-07 12:50:52 -08:00
parent 1e4515c548
commit 7673e3ac3f
2 changed files with 15 additions and 0 deletions

View file

@ -56,3 +56,15 @@ xcalloc (size_t nmemb, size_t size)
return buf;
}
void *
xrealloc (void *buf, size_t size)
{
buf = realloc (buf, size);
if (!buf) {
CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting\n");
exit (1);
}
return buf;
}

View file

@ -34,4 +34,7 @@ xmalloc (size_t size);
void *
xcalloc (size_t nmemb, size_t size);
void *
xrealloc (void *buf, size_t size);
#endif