From 20d78e939aa218e85ef19013769494851d863f13 Mon Sep 17 00:00:00 2001 From: jbj Date: Tue, 21 Sep 1999 03:22:53 +0000 Subject: 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 --- system.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'system.h') 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 #endif +#if HAVE_ERR_H +#include +#endif + #if HAVE_MALLOC_H #include #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 #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 -- cgit v1.2.3