cb63a575751c4a60e48340bd320934cccb053f75 braney Wed May 29 13:14:08 2019 -0700 some tweaks to the lm allocater to allow it to use a memory block passed into rather than allocating its own memory. Also a checkpoint routine for the memory allocators that allows a caller to find out how much memory has been allocated since the last time it was called. diff --git src/inc/localmem.h src/inc/localmem.h index c9b4632..3b8231e 100644 --- src/inc/localmem.h +++ src/inc/localmem.h @@ -4,30 +4,36 @@ * a lot of little to medium size pieces of memory are * allocated, and then disposed of all at once. * * This file is copyright 2002 Jim Kent, but license is hereby * granted for all use - public, private or commercial. */ #ifndef LOCALMEM_H #define LOCALMEM_H struct lm *lmInit(int blockSize); /* Create a local memory pool. Parameters are: * blockSize - how much system memory to allocate at a time. Can * pass in zero and a reasonable default will be used. */ +struct lm *lmInitWMem(void *mem, int blockSize); +/* Create a local memory pool. Don't do any memory allocation. Parameters are: + * mem -- the memory to use for the blocks + * blockSize - how much memory has been allocated. If this is exhausted, an errAbort occurs. + */ + void lmCleanup(struct lm **pLm); /* Clean up a local memory pool. */ size_t lmAvailable(struct lm *lm); // Returns currently available memory in pool size_t lmSize(struct lm *lm); // Returns current size of pool, even for memory already allocated void *lmAlloc(struct lm *lm, size_t size); /* Allocate memory from local pool. */ void *lmAllocMoreMem(struct lm *lm, void *pt, size_t oldSize, size_t newSize); /* Adjust memory size on a block, possibly relocating it. If block is grown, * new memory is zeroed. NOTE: in RARE cases, same pointer may be returned. */