]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/alloc.c
Merge remote-tracking branch 'origin/master'
[libucw.git] / ucw / alloc.c
index 4528e09757f16d4a00e444e1a33973921fcc5736..816da2a055cfe25d21a135aacd5604a16f219d3b 100644 (file)
@@ -7,7 +7,7 @@
  *     of the GNU Lesser General Public License.
  */
 
-#include "ucw/lib.h"
+#include <ucw/lib.h>
 
 #include <stdlib.h>
 #include <string.h>
@@ -39,3 +39,13 @@ xfree(void *ptr)
    */
   free(ptr);
 }
+
+void *
+xrealloc(void *old, size_t size)
+{
+  /* We assume that realloc(NULL, x) works like malloc(x), which is true with the glibc. */
+  void *x = realloc(old, size);
+  if (!x && size)
+    die("Cannot reallocate %zu bytes of memory", size);
+  return x;
+}