summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 902b92e)
raw | patch | inline | side by side (parent: 902b92e)
author | Brad Roberts <braddr@puremagic.com> | |
Sun, 15 May 2005 02:04:25 +0000 (19:04 -0700) | ||
committer | Petr Baudis <xpasky@machine.sinus.cz> | |
Sun, 15 May 2005 09:58:12 +0000 (11:58 +0200) |
xmalloc() and xrealloc() now take their sizes as size_t-type arguments.
Introduced complementary xcalloc().
Signed-off-by: Brad Roberts <braddr@puremagic.com>
Signed-off-by: Petr Baudis <pasky@ucw.cz>
Introduced complementary xcalloc().
Signed-off-by: Brad Roberts <braddr@puremagic.com>
Signed-off-by: Petr Baudis <pasky@ucw.cz>
cache.h | patch | blob | history |
index c06b94107e0e1149be0ad642812e8d4a42f2193c..7696766dde0c8bd566a4529d6fa755da32f1482e 100644 (file)
--- a/cache.h
+++ b/cache.h
void parse_date(char *date, char *buf, int bufsize);
void datestamp(char *buf, int bufsize);
-static inline void *xmalloc(int size)
+static inline void *xmalloc(size_t size)
{
void *ret = malloc(size);
if (!ret)
return ret;
}
-static inline void *xrealloc(void *ptr, int size)
+static inline void *xrealloc(void *ptr, size_t size)
{
void *ret = realloc(ptr, size);
if (!ret)
return ret;
}
+static inline void *xcalloc(size_t nmemb, size_t size)
+{
+ void *ret = calloc(nmemb, size);
+ if (!ret)
+ die("Out of memory, calloc failed");
+ return ret;
+}
+
#endif /* CACHE_H */