MINOR: debug: enable memory poisonning to use byte 0

When debugging an issue, sometimes it can be useful to be able to use
byte 0 to poison memory areas, resulting in the same effect as a calloc().
This patch changes the default mem_poison_byte to -1 to disable it so that
all positive values are usable.
This commit is contained in:
Willy Tarreau 2015-10-08 14:12:13 +02:00
parent a088d316b7
commit 067ac9f4b6
3 changed files with 5 additions and 5 deletions

View File

@ -62,7 +62,7 @@
static inline void *p_malloc(size_t size) static inline void *p_malloc(size_t size)
{ {
void *ret = malloc(size); void *ret = malloc(size);
if (mem_poison_byte && ret) if (mem_poison_byte >= 0 && ret)
memset(ret, mem_poison_byte, size); memset(ret, mem_poison_byte, size);
return ret; return ret;
} }

View File

@ -43,8 +43,8 @@ struct pool_head {
char name[12]; /* name of the pool */ char name[12]; /* name of the pool */
}; };
/* poison each newly allocated area with this byte if not null */ /* poison each newly allocated area with this byte if >= 0 */
extern char mem_poison_byte; extern int mem_poison_byte;
/* /*
* This function destroys a pull by freeing it completely. * This function destroys a pull by freeing it completely.
@ -141,7 +141,7 @@ static inline void *pool_alloc2(struct pool_head *pool)
void *p; void *p;
p = pool_alloc_dirty(pool); p = pool_alloc_dirty(pool);
if (p && mem_poison_byte) if (p && mem_poison_byte >= 0)
memset(p, mem_poison_byte, pool->size); memset(p, mem_poison_byte, pool->size);
return p; return p;
} }

View File

@ -20,7 +20,7 @@
#include <proto/log.h> #include <proto/log.h>
static struct list pools = LIST_HEAD_INIT(pools); 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 /* Try to find an existing shared pool with the same characteristics and
* returns it, otherwise creates this one. NULL is returned if no memory * returns it, otherwise creates this one. NULL is returned if no memory