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:
parent
a088d316b7
commit
067ac9f4b6
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <proto/log.h>
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue