summaryrefslogtreecommitdiff
path: root/system.h
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-09-16 17:28:22 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-09-17 12:32:04 +0300
commit14925811396c7f006b9b305cdce297366c648295 (patch)
treecec55c371e43bc6e762f9e2e87c48c63209c9b9b /system.h
parent3ef73d4d9df6666e5fa3ad772cb4c177f0fd3440 (diff)
downloadlibrpm-tizen-14925811396c7f006b9b305cdce297366c648295.tar.gz
librpm-tizen-14925811396c7f006b9b305cdce297366c648295.tar.bz2
librpm-tizen-14925811396c7f006b9b305cdce297366c648295.zip
Always use build + use our own allocator functions
- Consistent across platforms and will allow some things macros dont and memory checkers these days are smart enough to get decent output anyway - Minimal namespacing with r-prefix, add compatibility macros to system.h for now so we dont have to change the entire codebase for this - Also make rpmutil.h where the declarations and gcc __attribute__ macros are available everywhere
Diffstat (limited to 'system.h')
-rw-r--r--system.h65
1 files changed, 9 insertions, 56 deletions
diff --git a/system.h b/system.h
index 64c4003de..dc053eec1 100644
--- a/system.h
+++ b/system.h
@@ -225,18 +225,6 @@ typedef char * security_context_t;
#define rpm_execcon(_v, _fn, _av, _envp) (0)
#endif
-/**
- * Wrapper to free(3), permit NULL, return NULL.
- * @param p memory to free
- * @return NULL always
- */
-static inline
-void * _free(void * p)
-{
- if (p != NULL) free(p);
- return NULL;
-}
-
#if WITH_CAP
#include <sys/capability.h>
#else
@@ -247,54 +235,19 @@ typedef void * cap_t;
#include <acl/libacl.h>
#endif
-/**
- * Wrapper to free(3), permit NULL, return NULL.
- * For documenting cases where const is used to protect long-lived
- * non-const data that's supposed to be freed.
- * @param p memory to free
- * @return NULL always
- */
-static inline
-void * _constfree(const void * p)
-{
- if (p != NULL) free((void *)p);
- return NULL;
-}
-
-/* FIX: these are macros */
-/**
- */
-void * xmalloc (size_t size);
-
-/**
- */
-void * xcalloc (size_t nmemb, size_t size);
-
-/**
- * @todo Annotate ptr with returned/out.
- */
-void * xrealloc (void * ptr,
- size_t size);
-
-/**
- */
-char * xstrdup (const char *str);
-
-/**
- */
-void * vmefail(size_t size);
-
#if HAVE_MCHECK_H
#include <mcheck.h>
-/* Memory allocation via macro defs to get meaningful locations from mtrace() */
-#if defined(__GNUC__)
-#define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
-#define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
-#define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
-#define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
-#endif /* defined(__GNUC__) */
#endif /* HAVE_MCHECK_H */
+#include "rpmio/rpmutil.h"
+/* compatibility macros to avoid a mass-renaming all over the codebase */
+#define xmalloc(_size) rmalloc((_size))
+#define xcalloc(_nmemb, _size) rcalloc((_nmemb), (_size))
+#define xrealloc(_ptr, _size) rrealloc((_ptr), (_size))
+#define xstrdup(_str) rstrdup((_str))
+#define _free(_ptr) rfree((_ptr))
+#define _constfree(_ptr) rfree((void *)(_ptr))
+
/* Retrofit glibc __progname */
#if defined __GLIBC__ && __GLIBC__ >= 2
#if __GLIBC_MINOR__ >= 1