#define SMALLOC_POST_RED 0x5aa55aa5U
unsigned int smalloc_pool_size = INITIAL_SIZE;
+#ifdef SMALLOC_REDZONE
static const int int_mask = sizeof(int) - 1;
+#endif
struct pool {
struct fio_mutex *lock; /* protects this pool */
if (ptr == MAP_FAILED)
goto out_fail;
- memset(ptr, 0, alloc_size);
pool->map = ptr;
pool->bitmap = (void *) ptr + (pool->nr_blocks * SMALLOC_BPL);
+ memset(pool->bitmap, 0, bitmap_blocks * sizeof(unsigned int));
pool->lock = fio_mutex_init(FIO_MUTEX_UNLOCKED);
if (!pool->lock)
global_read_unlock();
- assert(pool);
- sfree_pool(pool, ptr);
+ if (pool) {
+ sfree_pool(pool, ptr);
+ return;
+ }
+
+ log_err("smalloc: ptr %p not from smalloc pool\n", ptr);
}
static void *__smalloc_pool(struct pool *pool, size_t size)
void *scalloc(size_t nmemb, size_t size)
{
- void *ret;
-
- ret = smalloc(nmemb * size);
- if (ret)
- memset(ret, 0, nmemb * size);
-
- return ret;
+ return smalloc(nmemb * size);
}
char *smalloc_strdup(const char *str)