diff --git a/boilerplate/xmalloc.c b/boilerplate/xmalloc.c index 10d1cef47..8da056809 100644 --- a/boilerplate/xmalloc.c +++ b/boilerplate/xmalloc.c @@ -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; +} diff --git a/boilerplate/xmalloc.h b/boilerplate/xmalloc.h index bc1ab69eb..1f0fadf6e 100644 --- a/boilerplate/xmalloc.h +++ b/boilerplate/xmalloc.h @@ -34,4 +34,7 @@ xmalloc (size_t size); void * xcalloc (size_t nmemb, size_t size); +void * +xrealloc (void *buf, size_t size); + #endif