jabberd2  2.3.6
Macros | Functions
pool.c File Reference
#include "util.h"
#include "pool.h"

Go to the source code of this file.

Macros

#define _pool__malloc   malloc
 
#define _pool__free   free
 

Functions

pool_t _pool_new (const char *zone, int line)
 make an empty pool More...
 
static void _pool_heap_free (void *arg)
 free a heap More...
 
static void _pool_cleanup_append (pool_t p, struct pfree *pf)
 mem should always be freed last More...
 
static struct pfree_pool_free (pool_t p, pool_cleanup_t f, void *arg)
 create a cleanup tracker More...
 
static struct pheap_pool_heap (pool_t p, int size)
 create a heap and make sure it get's cleaned up More...
 
pool_t _pool_new_heap (int size, const char *zone, int line)
 
void * pmalloc (pool_t p, int size)
 
void * pmalloc_x (pool_t p, int size, char c)
 
void * pmalloco (pool_t p, int size)
 easy safety utility (for creating blank mem for structs, etc) More...
 
char * pstrdup (pool_t p, const char *src)
 XXX efficient: move this to const char * and then loop throug the existing heaps to see if src is within a block in this pool. More...
 
char * pstrdupx (pool_t p, const char *src, int len)
 use given size More...
 
int pool_size (pool_t p)
 
void pool_free (pool_t p)
 
void pool_cleanup (pool_t p, pool_cleanup_t f, void *arg)
 public cleanup utils, insert in a way that they are run FIFO, before mem frees More...
 
void pool_stat (int full)
 

Macro Definition Documentation

#define _pool__malloc   malloc

Definition at line 39 of file pool.c.

Referenced by _pool_free(), _pool_heap(), _pool_new(), and pmalloc().

#define _pool__free   free

Definition at line 40 of file pool.c.

Referenced by _pool_heap_free(), pmalloc(), and pool_free().

Function Documentation

pool_t _pool_new ( const char *  zone,
int  line 
)

make an empty pool

Definition at line 45 of file pool.c.

References _pool__malloc, pool_struct::cleanup, pool_struct::heap, pool_struct::size, xhash_new(), and xhash_put().

Referenced by _pool_new_heap().

static void _pool_heap_free ( void *  arg)
static

free a heap

Definition at line 72 of file pool.c.

References _pool__free, and pheap::block.

Referenced by _pool_heap().

static void _pool_cleanup_append ( pool_t  p,
struct pfree pf 
)
static

mem should always be freed last

Definition at line 81 of file pool.c.

References pool_struct::cleanup, pool_struct::cleanup_tail, and pfree::next.

Referenced by _pool_heap(), and pmalloc().

static struct pfree* _pool_free ( pool_t  p,
pool_cleanup_t  f,
void *  arg 
)
static

create a cleanup tracker

Definition at line 99 of file pool.c.

References _pool__malloc, pfree::arg, pfree::f, and pfree::next.

Referenced by _pool_heap(), pmalloc(), and pool_cleanup().

static struct pheap* _pool_heap ( pool_t  p,
int  size 
)
static

create a heap and make sure it get's cleaned up

Definition at line 113 of file pool.c.

References _pool__malloc, _pool_cleanup_append(), _pool_free(), _pool_heap_free(), pheap::block, pfree::heap, pheap::size, pool_struct::size, and pheap::used.

Referenced by _pool_new_heap(), and pmalloc().

pool_t _pool_new_heap ( int  size,
const char *  zone,
int  line 
)

Definition at line 133 of file pool.c.

References _pool_heap(), _pool_new(), and pool_struct::heap.

void* pmalloc ( pool_t  p,
int  size 
)
void* pmalloc_x ( pool_t  p,
int  size,
char  c 
)

Definition at line 174 of file pool.c.

References pmalloc().

void* pmalloco ( pool_t  p,
int  size 
)
char* pstrdup ( pool_t  p,
const char *  src 
)
char* pstrdupx ( pool_t  p,
const char *  src,
int  len 
)
int pool_size ( pool_t  p)

Definition at line 219 of file pool.c.

References pool_struct::size.

void pool_free ( pool_t  p)
void pool_cleanup ( pool_t  p,
pool_cleanup_t  f,
void *  arg 
)
void pool_stat ( int  full)

Definition at line 285 of file pool.c.

Referenced by JABBER_MAIN().