rpool.h revision 1
/*
* Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
* $Id: rpool.h,v 1.16 2003/09/05 23:07:49 ca Exp $
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
** libsm resource pools
** See libsm/rpool.html for documentation.
*/
#ifndef SM_RPOOL_H
# define SM_RPOOL_H
/*
** Each memory pool object consists of an SM_POOLLINK_T,
** followed by a platform specific amount of padding,
** followed by 'poolsize' bytes of pool data,
** where 'poolsize' is the value of rpool->sm_poolsize at the time
** the pool is allocated.
*/
typedef struct sm_poollink SM_POOLLINK_T;
struct sm_poollink
{
};
typedef SM_RPOOL_RFREE_T *SM_RPOOL_ATTACH_T;
typedef struct sm_resource SM_RESOURCE_T;
struct sm_resource
{
/*
** Function for freeing this resource. It may be NULL,
** meaning that this resource has already been freed.
*/
void *sm_rcontext; /* resource data */
};
# define SM_RLIST_MAX 511
typedef struct sm_rlist SM_RLIST_T;
struct sm_rlist
{
};
typedef struct
{
/* Points to SmRpoolMagic, or is NULL if rpool is freed. */
const char *sm_magic;
/*
** If this rpool object has no parent, then sm_parentlink
** is NULL. Otherwise, we set *sm_parentlink = NULL
** when this rpool is freed, so that it isn't freed a
** second time when the parent is freed.
*/
/*
** Memory pools
*/
/* Size of the next pool to be allocated, not including the header. */
/*
** If an sm_rpool_malloc_x request is too big to fit
** in the current pool, and the request size > bigobjectsize,
** then the object will be given its own malloc'ed block.
** sm_bigobjectsize <= sm_poolsize. The maximum wasted space
** at the end of a pool is maxpooledobjectsize - 1.
*/
/* Points to next free byte in the current pool. */
char *sm_poolptr;
/*
** Number of bytes available in the current pool.
** Initially 0. Set to 0 by sm_rpool_free.
*/
/* Linked list of memory pools. Initially NULL. */
/*
** Resource lists
*/
/*
** Number of available resource slots in current list.
** Initially 0. Set to 0 by sm_rpool_free.
*/
/* Linked list of resource lists. Initially NULL. */
#if _FFR_PERF_RPOOL
int sm_nbigblocks;
int sm_npools;
#endif /* _FFR_PERF_RPOOL */
} SM_RPOOL_T;
extern SM_RPOOL_T *
SM_RPOOL_T *_parent));
extern void
SM_RPOOL_T *_rpool));
# if SM_HEAP_CHECK
extern void *
char *_file,
int _line,
int _group));
extern void *
char *_file,
int _line,
int _group));
# else /* SM_HEAP_CHECK */
extern void *
extern void *
# endif /* SM_HEAP_CHECK */
#else /* DO_NOT_USE_STRCPY */
#endif /* DO_NOT_USE_STRCPY */
extern SM_RPOOL_ATTACH_T
void *_rcontext));
# define sm_rpool_detach(a) ((void)(*(a) = NULL))
extern void
#endif /* ! SM_RPOOL_H */