]> mj.ucw.cz Git - libucw.git/commitdiff
Use size_t in xmalloc() and xrealloc().
authorMartin Mares <mj@ucw.cz>
Tue, 2 Sep 2008 20:09:44 +0000 (22:09 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 29 Mar 2011 10:52:00 +0000 (12:52 +0200)
ucw/alloc.c
ucw/lib.h
ucw/realloc.c

index 4f531366ec6eedaa6643732b3cc670a39ee40cb0..4562b81521a4340d6845b57e0ca1ab698df75bf4 100644 (file)
 #include <string.h>
 
 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;
 }
 
index 79843c0e9a65da364a719f5d82ee4945c97e8118..9612e6c711148a6e184df95a89920339e4dc1765 100644 (file)
--- a/ucw/lib.h
+++ b/ucw/lib.h
@@ -159,8 +159,8 @@ void assert_failed_noinfo(void) NONRET;
 #define xrealloc ucw_xrealloc
 #define xfree ucw_xfree
 
-void *xmalloc(uns) LIKE_MALLOC;                        /** Allocate memory and die() if there is none. **/
-void *xrealloc(void *, uns);                   /** Reallocate memory and die() if there is none. **/
+void *xmalloc(size_t) LIKE_MALLOC;             /** Allocate memory and die() if there is none. **/
+void *xrealloc(void *, size_t);                        /** Reallocate memory and die() if there is none. **/
 void xfree(void *);                            /** Free memory allocated by xmalloc() or xrealloc(). **/
 
 void *xmalloc_zero(uns) LIKE_MALLOC;           /** Allocate memory and fill it by zeroes. **/
index 51b50dec52f3ecb693f93eb8757e796c324bf687..66b001a2aebef3fd4f0549e346866fecc540cc69 100644 (file)
 #include <stdlib.h>
 
 void *
-xrealloc(void *old, uns size)
+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)
-    die("Cannot reallocate %d bytes of memory", size);
+    die("Cannot reallocate %zu bytes of memory", size);
   return x;
 }