summaryrefslogtreecommitdiff
path: root/system.h
diff options
context:
space:
mode:
authorjbj <devnull@localhost>1999-09-21 03:22:53 +0000
committerjbj <devnull@localhost>1999-09-21 03:22:53 +0000
commit20d78e939aa218e85ef19013769494851d863f13 (patch)
tree9fddb9815dafcdd8e7eb20bb4ec9fe3a80270b39 /system.h
parent78ce864c5eee9b2d4fc3a3a4a201818f4e500d50 (diff)
downloadlibrpm-tizen-20d78e939aa218e85ef19013769494851d863f13.tar.gz
librpm-tizen-20d78e939aa218e85ef19013769494851d863f13.tar.bz2
librpm-tizen-20d78e939aa218e85ef19013769494851d863f13.zip
fix: command line install had header memory leak.
check for NULL on all memory allocations. free rpmrc mallocs on exit. permit run time leak detection. CVS patchset: 3311 CVS date: 1999/09/21 03:22:53
Diffstat (limited to 'system.h')
-rw-r--r--system.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/system.h b/system.h
index db486cd67..7d6f9747b 100644
--- a/system.h
+++ b/system.h
@@ -184,14 +184,39 @@ char *alloca ();
#include <limits.h>
#endif
+#if HAVE_ERR_H
+#include <err.h>
+#endif
+
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
+/*@only@*/ void * xmalloc (size_t size);
+/*@only@*/ void * xcalloc (size_t nmemb, size_t size);
+/*@only@*/ void * xrealloc (void *ptr, size_t size);
+/*@only@*/ char * xstrdup (const char *str);
+void *vmefail(void);
+
#if HAVE_MCHECK_H
#include <mcheck.h>
#endif
+
+#if HAVE_MCHECK_H && defined(__GNUC__)
+
+/* Memory allocation via macro defs to get meaningful locations from mtrace() */
+
+#define xmalloc(_size) (malloc(_size) ? : vmefail())
+
+#define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail())
+
+#define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail())
+
+#define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str)))
+
+#endif /* HAVE_MCHECK_H && defined(__GNUC__) */
+
#if HAVE_NETDB_H
#ifndef __LCLINT__
#include <netdb.h>