]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/alloc.c
Table: renamed table_col_order[_by_name] -> table_set_col_order[_by_name]
[libucw.git] / ucw / alloc.c
index bed8c51f104a0d78dbe3e90023ea346fd4fb2320..816da2a055cfe25d21a135aacd5604a16f219d3b 100644 (file)
@@ -7,26 +7,22 @@
  *     of the GNU Lesser General Public License.
  */
 
-#include "ucw/lib.h"
+#include <ucw/lib.h>
 
 #include <stdlib.h>
 #include <string.h>
 
-#ifndef DEBUG_DMALLOC
-
 void *
-xmalloc(uns size)
+xmalloc(size_t size)
 {
   void *x = malloc(size);
   if (!x)
-    die("Cannot allocate %d bytes of memory", size);
+    die("Cannot allocate %zu bytes of memory", size);
   return x;
 }
 
-#endif
-
 void *
-xmalloc_zero(uns size)
+xmalloc_zero(size_t size)
 {
   void *x = xmalloc(size);
   bzero(x, size);
@@ -43,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;
+}