diff --git a/include/common/debug.h b/include/common/debug.h index ac7288a35..1f84c658c 100644 --- a/include/common/debug.h +++ b/include/common/debug.h @@ -62,7 +62,7 @@ static inline void *p_malloc(size_t size) { void *ret = malloc(size); - if (mem_poison_byte && ret) + if (mem_poison_byte >= 0 && ret) memset(ret, mem_poison_byte, size); return ret; } diff --git a/include/common/memory.h b/include/common/memory.h index 965dfc488..c76b4ca3b 100644 --- a/include/common/memory.h +++ b/include/common/memory.h @@ -43,8 +43,8 @@ struct pool_head { char name[12]; /* name of the pool */ }; -/* poison each newly allocated area with this byte if not null */ -extern char mem_poison_byte; +/* poison each newly allocated area with this byte if >= 0 */ +extern int mem_poison_byte; /* * This function destroys a pull by freeing it completely. @@ -141,7 +141,7 @@ static inline void *pool_alloc2(struct pool_head *pool) void *p; p = pool_alloc_dirty(pool); - if (p && mem_poison_byte) + if (p && mem_poison_byte >= 0) memset(p, mem_poison_byte, pool->size); return p; } diff --git a/src/memory.c b/src/memory.c index 61c150bfd..d9cef64b6 100644 --- a/src/memory.c +++ b/src/memory.c @@ -20,7 +20,7 @@ #include static struct list pools = LIST_HEAD_INIT(pools); -char mem_poison_byte = 0; +int mem_poison_byte = -1; /* Try to find an existing shared pool with the same characteristics and * returns it, otherwise creates this one. NULL is returned if no memory