/* $Cambridge: hermes/src/prayer/accountd/pool.h,v 1.1.1.1 2003/04/15 13:00:03 dpc22 Exp $ */
/************************************************
* Prayer - a Webmail Interface *
************************************************/
/* Copyright (c) University of Cambridge 2000 - 2002 */
/* See the file NOTICE for conditions of use and distribution. */
/* External Interfere Prototypes for pool.c */
/* Pool:
* Memory allocated in pools which can be freed as a single operation.
* Idea is to make memory management for transient data structures
* a bit easier. Does use more memory than direct malloc/free.
*
* Methods:
* pool_create (initialise pool data structure)
* pool_alloc (allocate memory using nominated pool)
* pool_free (free all memory allocated in this pool).
*/
struct pool_elt {
struct pool_elt *next;
char data[1];
};
struct pool {
struct pool_elt *first;
struct pool_elt *last;
unsigned long blocksize;
unsigned long avail;
};
struct pool *pool_create(unsigned long blocksize);
void pool_free(struct pool *p);
void *pool_alloc(struct pool *p, unsigned long size);
char *pool_strdup(struct pool *p, char *value);
char *pool_strcat(struct pool *p, char *s1, char *s2);
char *pool_strcat3(struct pool *p, char *s1, char *s2, char *s3);
unsigned long pool_vprintf_size(char *fmt, va_list ap);
void pool_vprintf(char *target, char *fmt, va_list ap);
char *pool_printf(struct pool *p, char *fmt, ...);
/* Malloc pool in 4Kbyte chunks */
#define PREFERRED_POOL_BLOCK_SIZE (4096)
syntax highlighted by Code2HTML, v. 0.9.1