]> git.deb.at Git - pkg/abook.git/blobdiff - xmalloc.h
- add xstrdup to have proper checking for memory allocation failures
[pkg/abook.git] / xmalloc.h
index f8e0bc1fd09b31e54b7dbf7094216accbeca1fc7..9b0f6de03098c5f18cfd2225ac15c18f87d589da 100644 (file)
--- a/xmalloc.h
+++ b/xmalloc.h
@@ -3,11 +3,21 @@
 
 #include <stdlib.h> /* for size_t */
 
+/*
+ * avoid possible collision with readline xmalloc functions
+ */
+
+#define xmalloc                _xmalloc_xmalloc
+#define xrealloc       _xmalloc_xrealloc
+
 void           xmalloc_set_error_handler(void (*)(int));
 void *         xmalloc(size_t);
 void *         xmalloc0(size_t);
 void *         xmalloc_inc(size_t, size_t);
 void *         xrealloc(void *, size_t);
-void           xfree(void *);
+void *         xrealloc_inc(void *, size_t, size_t);
+char *         xstrdup(const char *s);
+
+#define xfree(ptr)     do { free(ptr); ptr = NULL; } while(0)
 
 #endif