Made mempool.c threadsafe (#234)

This commit is contained in:
Lew Rossman
2018-09-03 10:29:41 -04:00
parent f7d54810ea
commit 6e73b6a4f5
4 changed files with 100 additions and 198 deletions

View File

@@ -3,41 +3,17 @@
**
** Header for mempool.c
**
** The type alloc_handle_t provides an opaque reference to the
** alloc pool - only the alloc routines know its structure.
** A simple pooled memory allocator
*/
#ifndef MEMPOOL_H
#define MEMPOOL_H
#ifndef DLLEXPORT
#ifdef DLL
#ifdef __cplusplus
#define DLLEXPORT extern "C" __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllexport) __stdcall
#endif
#elif defined(CYGWIN)
#define DLLEXPORT __stdcall
#else
#ifdef __cplusplus
#define DLLEXPORT
#else
#define DLLEXPORT
#endif
#endif
#endif
struct Mempool;
typedef struct
{
long dummy;
} alloc_handle_t;
alloc_handle_t *AllocInit(void);
char *Alloc(long);
alloc_handle_t *AllocSetPool(alloc_handle_t *);
void AllocReset(void);
void AllocFreePool(void);
struct Mempool * mempool_create();
void mempool_delete(struct Mempool *mempool);
void mempool_reset(struct Mempool *mempool);
char * mempool_alloc(struct Mempool *mempool, size_t size);
#endif