From 7673e3ac3fc36042efcbccc3836d8bc81bdb94b3 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 7 Nov 2006 12:50:52 -0800 Subject: [PATCH] boilerplate: Add xrealloc function --- boilerplate/xmalloc.c | 12 ++++++++++++ boilerplate/xmalloc.h | 3 +++ 2 files changed, 15 insertions(+) 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