struct allocfree_pool *apool =
container_of(pool, struct allocfree_pool, pool);
- if (unlikely(size == 0 || size > POOL_MAX_ALLOC_SIZE))
- i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);
-
struct pool_block *block = calloc(1, SIZEOF_POOLBLOCK + size);
if (block == NULL)
i_fatal_status(FATAL_OUTOFMEM, "calloc(1, %"PRIuSIZE_T"): Out of memory",
container_of(pool, struct allocfree_pool, pool);
unsigned char *new_mem;
- if (unlikely(new_size == 0 || new_size > POOL_MAX_ALLOC_SIZE))
- i_panic("Trying to allocate %"PRIuSIZE_T" bytes", new_size);
-
if (mem == NULL)
return pool_allocfree_malloc(pool, new_size);
void *mem;
size_t alloc_size;
- if (unlikely(size == 0 || size > POOL_MAX_ALLOC_SIZE))
- i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);
-
#ifndef DEBUG
alloc_size = MEM_ALIGN(size);
#else
container_of(pool, struct alloconly_pool, pool);
unsigned char *new_mem;
- if (unlikely(new_size == 0 || new_size > POOL_MAX_ALLOC_SIZE))
- i_panic("Trying to allocate %"PRIuSIZE_T" bytes", new_size);
-
if (mem == NULL)
return pool_alloconly_malloc(pool, new_size);
struct datastack_pool *dpool =
container_of(pool, struct datastack_pool, pool);
- if (unlikely(size == 0 || size > POOL_MAX_ALLOC_SIZE))
- i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);
-
if (unlikely(dpool->data_stack_frame != data_stack_frame_id))
i_panic("pool_data_stack_malloc(): stack frame changed");
void *new_mem;
/* @UNSAFE */
- if (unlikely(new_size == 0 || new_size > POOL_MAX_ALLOC_SIZE))
- i_panic("Trying to allocate %"PRIuSIZE_T" bytes", new_size);
-
if (unlikely(dpool->data_stack_frame != data_stack_frame_id))
i_panic("pool_data_stack_realloc(): stack frame changed");
int old_errno = errno;
#endif
- if (unlikely(size == 0 || size > POOL_MAX_ALLOC_SIZE))
- i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);
-
mem = calloc(size, 1);
if (unlikely(mem == NULL)) {
i_fatal_status(FATAL_OUTOFMEM, "pool_system_malloc(%"PRIuSIZE_T
static void *pool_system_realloc(pool_t pool ATTR_UNUSED, void *mem,
size_t old_size, size_t new_size)
{
- if (unlikely(new_size == 0 || new_size > POOL_MAX_ALLOC_SIZE))
- i_panic("Trying to allocate %"PRIuSIZE_T" bytes", new_size);
-
if (mem == NULL) {
i_assert(old_size == 0);
return pool_system_malloc(pool, new_size);
static void *pool_unsafe_data_stack_malloc(pool_t pool ATTR_UNUSED,
size_t size)
{
- if (unlikely(size == 0 || size > POOL_MAX_ALLOC_SIZE))
- i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);
-
return t_malloc0(size);
}
void *new_mem;
/* @UNSAFE */
- if (new_size == 0 || new_size > POOL_MAX_ALLOC_SIZE)
- i_panic("Trying to allocate %"PRIuSIZE_T" bytes", new_size);
-
if (mem == NULL)
return pool_unsafe_data_stack_malloc(pool, new_size);
static inline void * ATTR_MALLOC ATTR_RETURNS_NONNULL
p_malloc(pool_t pool, size_t size)
{
+ if (unlikely(size == 0 || size > POOL_MAX_ALLOC_SIZE))
+ i_panic("Trying to allocate %" PRIuSIZE_T " bytes", size);
+
return pool->v->malloc(pool, size);
}
static inline void * ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
p_realloc(pool_t pool, void *mem, size_t old_size, size_t new_size)
{
+ if (unlikely(new_size == 0 || new_size > POOL_MAX_ALLOC_SIZE))
+ i_panic("Trying to allocate %" PRIuSIZE_T " bytes", new_size);
+
return pool->v->realloc(pool, mem, old_size, new_size);
}