]> mj.ucw.cz Git - osdd.git/commitdiff
util.c: Added xrealloc()
authorMartin Mares <mj@ucw.cz>
Sat, 12 Oct 2013 20:45:27 +0000 (22:45 +0200)
committerMartin Mares <mj@ucw.cz>
Sat, 12 Oct 2013 20:45:27 +0000 (22:45 +0200)
osd.h
util.c

diff --git a/osd.h b/osd.h
index 78b0a26189922c4990d36af1e1baccefafd0f845..3c7c5b74cbe89bf535ebb6bee40411a6875ae341 100644 (file)
--- 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 f9cd0c2bc59a3da2502c1ca510e112c3d4fbaf54..911e18bb764cd973b76a27867a8934959c7560a3 100644 (file)
--- 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)
 {