char name[12]; /* name of the pool */
};
+/* poison each newly allocated area with this byte if not null */
+extern char mem_poison_byte;
/* Allocate a new entry for pool <pool>, and return it for immediate use.
* NULL is returned if no memory is available for a new creation.
" [ -p <pidfile> ] [ -m <max megs> ] [ -C <dir> ]\n"
" -v displays version ; -vv shows known build options.\n"
" -d enters debug mode ; -db only disables background mode.\n"
+ " -dM[<byte>] poisons memory with <byte> (defaults to 0x50)\n"
" -V enters verbose mode (disables quiet mode)\n"
" -D goes daemon ; -C changes to <dir> before loading files.\n"
" -q quiet mode : don't display messages\n"
arg_mode |= MODE_VERBOSE;
else if (*flag == 'd' && flag[1] == 'b')
arg_mode |= MODE_FOREGROUND;
+ else if (*flag == 'd' && flag[1] == 'M')
+ mem_poison_byte = flag[2] ? strtol(flag + 2, NULL, 0) : 'P';
else if (*flag == 'd')
arg_mode |= MODE_DEBUG;
else if (*flag == 'c')
#include <proto/log.h>
static struct list pools = LIST_HEAD_INIT(pools);
+char mem_poison_byte = 0;
/* Try to find an existing shared pool with the same characteristics and
* returns it, otherwise creates this one. NULL is returned if no memory
if (pool->limit && (pool->allocated >= pool->limit))
return NULL;
- ret = MALLOC(pool->size);
+ ret = CALLOC(1, pool->size);
if (!ret) {
pool_gc2();
- ret = MALLOC(pool->size);
+ ret = CALLOC(1, pool->size);
if (!ret)
return NULL;
}
+ if (mem_poison_byte)
+ memset(ret, mem_poison_byte, pool->size);
pool->allocated++;
pool->used++;
return ret;