Code

debugging: XMALLOC_POISON
authorJunio C Hamano <junkio@cox.net>
Tue, 8 Aug 2006 19:23:47 +0000 (12:23 -0700)
committerJunio C Hamano <junkio@cox.net>
Tue, 8 Aug 2006 19:24:13 +0000 (12:24 -0700)
Compile with -DXMALLOC_POISON=1 to catch errors from using uninitialized
memory returned by xmalloc.

Signed-off-by: Junio C Hamano <junkio@cox.net>
git-compat-util.h

index 93f558056dec457570bf2867dc6c75cd5891d2f2..3bcf5b13f2c7bab387b02bd3075629a9d14c5feb 100644 (file)
@@ -91,6 +91,9 @@ static inline void *xmalloc(size_t size)
                ret = malloc(1);
        if (!ret)
                die("Out of memory, malloc failed");
+#ifdef XMALLOC_POISON
+       memset(ret, 0xA5, size);
+#endif
        return ret;
 }