Making memorypool.c reentrant and adding test
This commit is contained in:
23
src/epanet.c
23
src/epanet.c
@@ -185,6 +185,29 @@ int DLLEXPORT ENepanet(const char *f1, const char *f2, const char *f3, void (*pv
|
||||
return (errcode);
|
||||
}
|
||||
|
||||
int DLLEXPORT EN_runproject(EN_ProjectHandle ph, const char *f1, const char *f2,
|
||||
const char *f3, void (*pviewprog)(char *))
|
||||
{
|
||||
int errcode = 0;
|
||||
EN_Project *p = NULL;
|
||||
|
||||
ERRCODE(EN_open(ph, f1, f2, f3));
|
||||
|
||||
p = (EN_Project*)(ph);
|
||||
p->viewprog = pviewprog;
|
||||
|
||||
if (p->out_files.Hydflag != USE) {
|
||||
ERRCODE(EN_solveH(ph));
|
||||
}
|
||||
|
||||
ERRCODE(EN_solveQ(ph));
|
||||
ERRCODE(EN_report(ph));
|
||||
|
||||
EN_close(ph);
|
||||
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int DLLEXPORT ENinit(char *f2, char *f3, int UnitsType,
|
||||
int HeadlossFormula) {
|
||||
int errcode = 0;
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
#endif
|
||||
#include "mempool.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define THREAD_LOCAL __declspec(thread)
|
||||
#else
|
||||
#define THREAD_LOCAL __thread
|
||||
#endif
|
||||
|
||||
/*
|
||||
** ALLOC_BLOCK_SIZE - adjust this size to suit your installation - it
|
||||
** should be reasonably large otherwise you will be mallocing a lot.
|
||||
@@ -54,7 +60,7 @@ typedef struct alloc_root_s
|
||||
** root - Pointer to the current pool.
|
||||
*/
|
||||
|
||||
static alloc_root_t *root;
|
||||
THREAD_LOCAL alloc_root_t *root;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user