From 69d6339d95453ec2fb380086c8f81a0812911958 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 12 Oct 2013 22:45:27 +0200 Subject: [PATCH] util.c: Added xrealloc() --- osd.h | 1 + util.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/osd.h b/osd.h index 78b0a26..3c7c5b7 100644 --- a/osd.h +++ b/osd.h @@ -22,6 +22,7 @@ void NONRET FORMAT_CHECK(printf,1,2) die(char *fmt, ...); #endif void *xmalloc(int size); +void *xrealloc(void *ptr, int size); timestamp_t get_current_time(void); diff --git a/util.c b/util.c index f9cd0c2..911e18b 100644 --- a/util.c +++ b/util.c @@ -31,6 +31,15 @@ xmalloc(int size) return p; } +void * +xrealloc(void *ptr, int size) +{ + void *p = realloc(ptr, size); + if (!p) + die("Failed to re-allocate %d bytes of memory", size); + return p; +} + timestamp_t get_current_time(void) { -- 2.39.2