inc/localmem.h

Go to the documentation of this file.
00001 /* LocalMem.h - local memory routines. 
00002  * 
00003  * These routines are meant for the sort of scenario where
00004  * a lot of little to medium size pieces of memory are
00005  * allocated, and then disposed of all at once.
00006  *
00007  * This file is copyright 2002 Jim Kent, but license is hereby
00008  * granted for all use - public, private or commercial. */
00009 
00010 struct lm *lmInit(int blockSize);
00011 /* Create a local memory pool. Parameters are:
00012  *      blockSize - how much system memory to allocate at a time.  Can
00013  *                  pass in zero and a reasonable default will be used.
00014  */
00015 
00016 void lmCleanup(struct lm **pLm);
00017 /* Clean up a local memory pool. */
00018 
00019 void *lmAlloc(struct lm *lm, size_t size);
00020 /* Allocate memory from local pool. */
00021 
00022 char *lmCloneString(struct lm *lm, char *string);
00023 /* Return local mem copy of string. */
00024 
00025 struct slName *lmSlName(struct lm *lm, char *name);
00026 /* Return slName in memory. */
00027 
00028 void *lmCloneMem(struct lm *lm, void *pt, size_t size);
00029 /* Return a local mem copy of memory block. */
00030 
00031 #define lmAllocVar(lm, pt) (pt = lmAlloc(lm, sizeof(*pt)));
00032 /* Shortcut to allocating a single variable in local mem and
00033  * assigning pointer to it. */
00034 
00035 #define lmAllocArray(lm, pt, size) (pt = lmAlloc(lm, sizeof(*pt) * (size)))
00036 /* Shortcut to allocating an array in local mem and
00037  * assigning pointer to it. */

Generated on Tue Dec 25 18:39:29 2007 for blat by  doxygen 1.5.2