-#define INITIAL_SIZE 1024*1024 /* new pool size */
-#define MAX_POOLS 4 /* maximum number of pools to setup */
+#define INITIAL_SIZE 8192*1024 /* new pool size */
+#define MAX_POOLS 128 /* maximum number of pools to setup */
#define SMALLOC_PRE_RED 0xdeadbeefU
#define SMALLOC_POST_RED 0x5aa55aa5U
unsigned int smalloc_pool_size = INITIAL_SIZE;
#define SMALLOC_PRE_RED 0xdeadbeefU
#define SMALLOC_POST_RED 0x5aa55aa5U
unsigned int smalloc_pool_size = INITIAL_SIZE;
void *map; /* map of blocks */
unsigned int *bitmap; /* blocks free/busy map */
unsigned int free_blocks; /* free blocks */
unsigned int nr_blocks; /* total blocks */
unsigned int next_non_full;
void *map; /* map of blocks */
unsigned int *bitmap; /* blocks free/busy map */
unsigned int free_blocks; /* free blocks */
unsigned int nr_blocks; /* total blocks */
unsigned int next_non_full;
static struct pool mp[MAX_POOLS];
static unsigned int nr_pools;
static unsigned int last_pool;
static struct pool mp[MAX_POOLS];
static unsigned int nr_pools;
static unsigned int last_pool;
bitmap_blocks = alloc_size / SMALLOC_BPL;
alloc_size += bitmap_blocks * sizeof(unsigned int);
pool->mmap_size = alloc_size;
bitmap_blocks = alloc_size / SMALLOC_BPL;
alloc_size += bitmap_blocks * sizeof(unsigned int);
pool->mmap_size = alloc_size;
- if (ftruncate(fd, alloc_size) < 0)
- goto out_unlink;
-
- ptr = mmap(NULL, alloc_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ ptr = mmap(NULL, alloc_size, PROT_READ|PROT_WRITE,
+ MAP_SHARED | OS_MAP_ANON, -1, 0);
memset(ptr, 0, alloc_size);
pool->map = ptr;
pool->bitmap = (void *) ptr + (pool->nr_blocks * SMALLOC_BPL);
memset(ptr, 0, alloc_size);
pool->map = ptr;
pool->bitmap = (void *) ptr + (pool->nr_blocks * SMALLOC_BPL);
fprintf(stderr, "smalloc: failed adding pool\n");
if (pool->map)
munmap(pool->map, pool->mmap_size);
fprintf(stderr, "smalloc: failed adding pool\n");
if (pool->map)
munmap(pool->map, pool->mmap_size);
ret = add_pool(&mp[0], INITIAL_SIZE);
assert(!ret);
}
static void cleanup_pool(struct pool *pool)
{
ret = add_pool(&mp[0], INITIAL_SIZE);
assert(!ret);
}
static void cleanup_pool(struct pool *pool)
{
if (hdr->prered != SMALLOC_PRE_RED) {
fprintf(stderr, "smalloc pre redzone destroyed!\n");
if (hdr->prered != SMALLOC_PRE_RED) {
fprintf(stderr, "smalloc pre redzone destroyed!\n");