commit b16aaa08b184f7f09433d6a989d387260eabb2bd
parent 58bb990d022b57d4ef27735e9c7b7dec9fc901ce
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 15 Jan 2021 13:49:32 +0100
Use a seperate allocator to manage the Star-VoXel data
Diffstat:
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/atrstm.c b/src/atrstm.c
@@ -23,10 +23,11 @@
#include <astoria/atrri.h>
#include <astoria/atrtp.h>
-#include <rsys/mem_allocator.h>
#include <star/suvm.h>
#include <star/svx.h>
+#include <rsys/cstr.h>
+
#include <omp.h>
/*******************************************************************************
@@ -66,6 +67,8 @@ release_atrstm(ref_T* ref)
if(atrstm->svx) SVX(device_ref_put(atrstm->svx));
if(atrstm->logger == &atrstm->logger__) logger_release(&atrstm->logger__);
str_release(&atrstm->name);
+ ASSERT(MEM_ALLOCATED_SIZE(&atrstm->svx_allocator) == 0);
+ mem_shutdown_proxy_allocator(&atrstm->svx_allocator);
MEM_RM(atrstm->allocator, atrstm);
}
@@ -136,7 +139,17 @@ atrstm_create
res = str_set(&atrstm->name, args->name);
if(res != RES_OK) {
- log_err(atrstm, "Cannot setup the gas mixture name to `%s'.\n", args->name);
+ log_err(atrstm, "Cannot setup the gas mixture name to `%s' -- %s.\n",
+ args->name, res_to_cstr(res));
+ goto error;
+ }
+
+ /* Setup the allocator used by the SVX library */
+ res = mem_init_proxy_allocator(&atrstm->svx_allocator, atrstm->allocator);
+ if(res != RES_OK) {
+ log_err(atrstm,
+ "Cannot initialise the allocator used to manager the Star-VoXel memory "
+ "-- %s.\n", res_to_cstr(res));
goto error;
}
@@ -166,7 +179,7 @@ atrstm_create
/* Create the Star-VoXel device */
res = svx_device_create
- (atrstm->logger, atrstm->allocator, atrstm->verbose, &atrstm->svx);
+ (atrstm->logger, &atrstm->svx_allocator, atrstm->verbose, &atrstm->svx);
if(res != RES_OK) goto error;
/* Build the octree */
diff --git a/src/atrstm_c.h b/src/atrstm_c.h
@@ -19,13 +19,13 @@
#include "atrstm.h"
#include <rsys/logger.h>
+#include <rsys/mem_allocator.h>
#include <rsys/ref_count.h>
#include <rsys/str.h>
/* Forward declaration of external data types */
struct atrri;
struct atrtp;
-struct mem_allocator;
struct suvm;
struct atrstm {
@@ -50,6 +50,7 @@ struct atrstm {
double wlen_range[2]; /* Spectral range in nm */
struct mem_allocator* allocator;
+ struct mem_allocator svx_allocator;
struct logger* logger;
struct logger logger__; /* Default logger */
int verbose;