mempool-allocfree.c revision 6b98c595aec0ab438e0e3c6faf220260f710f126
/* Copyright (c) 2017 Dovecot authors, see the included COPYING file */
/* @UNSAFE: whole file */
#include "lib.h"
#include "safe-memset.h"
#include "mempool.h"
#include "llist.h"
#define MAX_ALLOC_SIZE SSIZE_T_MAX
struct allocfree_pool {
int refcount;
struct pool_block *blocks;
#ifdef DEBUG
char *name;
#endif
bool clean_frees;
};
struct pool_block {
unsigned char *block;
};
static const struct pool_vfuncs static_allocfree_pool_vfuncs = {
};
static const struct pool static_allocfree_pool = {
.v = &static_allocfree_pool_vfuncs,
.alloconly_pool = FALSE,
};
{
struct allocfree_pool *pool;
#ifdef DEBUG
#endif
}
{
struct allocfree_pool *apool;
return pool;
}
{
if (apool->clean_frees)
#ifdef DEBUG
#endif
}
{
#ifdef DEBUG
struct allocfree_pool *apool =
#else
return "alloc";
#endif
}
{
struct allocfree_pool *apool =
}
{
struct allocfree_pool *apool =
/* erase the pointer before freeing anything, as the pointer may
exist inside the pool's memory area */
return;
}
{
}
static struct pool_block *
{
/* make sure the block we are dealing with is correct */
return block;
}
{
struct allocfree_pool *apool =
SIZEOF_POOLBLOCK + size);
}
{
struct allocfree_pool *apool =
return;
if (apool->clean_frees)
}
{
struct allocfree_pool *apool =
unsigned char *new_mem;
/* zero out new memory */
}
{
struct allocfree_pool *apool =
}
{
return 0;
}
{
struct allocfree_pool *apool =
return apool->total_alloc_used;
}
{
struct allocfree_pool *apool =
return apool->total_alloc_used +
}