diff --git a/lib/cgo/tests/testutils/common.c b/lib/cgo/tests/testutils/common.c index d55b1cf16..bc9a03289 100644 --- a/lib/cgo/tests/testutils/common.c +++ b/lib/cgo/tests/testutils/common.c @@ -3,6 +3,9 @@ #include #include +int MEMPOOLIDX = 0; +void *MEMPOOL[1024 * 256]; + GoInt_ isU8Eq(unsigned char p1[], unsigned char p2[], size_t len) { if (strncmp(p1, p2, len) == 0) { @@ -13,3 +16,15 @@ GoInt_ isU8Eq(unsigned char p1[], unsigned char p2[], size_t len) { printf("p2 %s\n", p2); return 0; } + +void * registerMemCleanup(void *p) { + int i; + for (i = 0; i < MEMPOOLIDX; i++) { + if(MEMPOOL[i] == NULL){ + MEMPOOL[i] = p; + return p; + } + } + MEMPOOL[MEMPOOLIDX++] = p; + return p; +} diff --git a/lib/cgo/tests/testutils/libsky_testutil.c b/lib/cgo/tests/testutils/libsky_testutil.c index 17240924d..712bd8b69 100644 --- a/lib/cgo/tests/testutils/libsky_testutil.c +++ b/lib/cgo/tests/testutils/libsky_testutil.c @@ -20,8 +20,8 @@ //Define function SKY_handle_close to avoid including libskycoin.h void SKY_handle_close(Handle p0); -int MEMPOOLIDX = 0; -void *MEMPOOL[1024 * 256]; +extern int MEMPOOLIDX = 0; +extern void *MEMPOOL[1024 * 256]; int JSONPOOLIDX = 0; json_value* JSON_POOL[128]; @@ -40,18 +40,6 @@ wallet_register WALLET_POOL[64]; int stdout_backup; int pipefd[2]; -void * registerMemCleanup(void *p) { - int i; - for (i = 0; i < MEMPOOLIDX; i++) { - if(MEMPOOL[i] == NULL){ - MEMPOOL[i] = p; - return p; - } - } - MEMPOOL[MEMPOOLIDX++] = p; - return p; -} - void freeRegisteredMemCleanup(void *p){ int i; for (i = 0; i < MEMPOOLIDX; i++) {