summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2006-11-07 16:32:48 +0000
committerAaron Griffin <aaron@archlinux.org>2006-11-07 16:32:48 +0000
commit34931106d7653e73bb474e1d72aee4044f7d5a5d (patch)
tree3363f88bf77b284af3424bed72e2cddc78ef1a41 /src
parenta8e44ff00ad5dd2d3f59bdf4c024d94db3f23ae4 (diff)
downloadpacman-34931106d7653e73bb474e1d72aee4044f7d5a5d.tar.xz
Added mcheck support for memory debugging
Diffstat (limited to 'src')
-rw-r--r--src/pacman/pacman.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 9259cf9d..1708d371 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -85,6 +85,32 @@ unsigned int maxcols = 80;
extern int neednl;
+#if defined(PACMAN_DEBUG) && !defined(CYGWIN) && !defined(BSD)
+void mcheck_abort(enum mcheck_status status)
+{
+ switch(status)
+ {
+ case MCHECK_DISABLED:
+ fputs("mcheck: disabled, no checking can be done", stderr);
+ break;
+ case MCHECK_OK:
+ fputs("mcheck: block ok", stderr);
+ break;
+ case MCHECK_HEAD:
+ fputs("mcheck: inconsistancy at block head (underrun)", stderr);
+ abort();
+ break;
+ case MCHECK_TAIL:
+ fputs("mcheck: inconsistancy at block tail (overrun)", stderr);
+ abort();
+ break;
+ case MCHECK_FREE:
+ fputs("mcheck: block has already been freed", stderr);
+ break;
+ };
+}
+#endif
+
/* Display usage/syntax for the specified operation.
* op: the operation code requested
* myname: basename(argv[0])
@@ -209,12 +235,10 @@ static void cleanup(int signum)
FREELIST(pm_targets);
FREECONF(config);
-#ifndef CYGWIN
-#ifndef BSD
+#if defined(PACMAN_DEBUG) && !defined(CYGWIN) && !defined(BSD)
/* debug */
muntrace();
#endif
-#endif
if(neednl) {
putchar('\n');
@@ -417,11 +441,10 @@ int main(int argc, char *argv[])
#endif
list_t *lp;
-#ifndef CYGWIN
-#ifndef BSD
+#if defined(PACMAN_DEBUG) && !defined(CYGWIN) && !defined(BSD)
/* debug */
mtrace();
-#endif
+ mcheck(0);
#endif
cenv = getenv("COLUMNS");