Skip to content

Commit

Permalink
table3
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisHeimbigner committed Sep 8, 2024
1 parent c04c63d commit 8931d80
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions include/ncplugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ extern "C" {

/* Known Plugin Dispatchers */
#ifdef USE_HDF5
EXTERNL const NC_PluginPathDispatch* NC4_hdf5_pluginpathtable;
EXTERNL const NC_PluginPathDispatch NC4_hdf5_pluginpathtable;
#endif
#ifdef NETCDF_ENABLE_NCZARR
EXTERNL const NC_PluginPathDispatch* NCZ_pluginpathtable;
EXTERNL const NC_PluginPathDispatch NCZ_pluginpathtable;
#endif

/* See the file netcdf_aux.h for plugin-related utility functions */
Expand Down
10 changes: 8 additions & 2 deletions libdispatch/ddispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,14 @@ NC_createglobalstate(void)
int stat = NC_NOERR;
const char* tmp = NULL;

if(nc_globalstate != NULL && nc_globalstate->initialized != 0) goto done;

if(nc_globalstate == NULL) {
nc_globalstate = calloc(1,sizeof(NCglobalstate));
if((nc_globalstate = calloc(1,sizeof(NCglobalstate)))==NULL) {stat = NC_ENOMEM; goto done;}
}

nc_globalstate->initialized = 1;

/* Initialize struct pointers */
if((nc_globalstate->rcinfo = calloc(1,sizeof(struct NCRCinfo)))==NULL)
{stat = NC_ENOMEM; goto done;}
Expand Down Expand Up @@ -210,7 +215,8 @@ NC_getglobalstate(void)
void
NC_freeglobalstate(void)
{
if(nc_globalstate != NULL) {
if(nc_globalstate != NULL && nc_globalstate->initialized != 0) {
nc_globalstate->initialized = 0;
nullfree(nc_globalstate->tempdir);
nullfree(nc_globalstate->home);
nullfree(nc_globalstate->cwd);
Expand Down
4 changes: 2 additions & 2 deletions libdispatch/dplugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ nc_plugin_path_initialize(void)

/* Initialize all the plugin path dispatchers and state*/
#ifdef USE_HDF5
gs->formatxstate.pluginapi[NC_FORMATX_NC_HDF5] = NC4_hdf5_pluginpathtable;
gs->formatxstate.pluginapi[NC_FORMATX_NC_HDF5] = &NC4_hdf5_pluginpathtable;
#endif
#ifdef NETCDF_ENABLE_NCZARR
gs->formatxstate.pluginapi[NC_FORMATX_NCZARR] = NCZ_pluginpathtable;
gs->formatxstate.pluginapi[NC_FORMATX_NCZARR] = &NCZ_pluginpathtable;
#endif
/* Initialize all the plugin path dispatcher states */
for(i=0;i<NC_FORMATX_COUNT;i++) {
Expand Down
6 changes: 1 addition & 5 deletions libhdf5/hdf5plugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int NC4_hdf5_plugin_path_write(void* state, size_t ndirs, char** const di
/**************************************************/
/* The HDF5 Plugin Path Dispatch table and functions */

static const NC_PluginPathDispatch pluginpathtable = {
const NC_PluginPathDispatch NC4_hdf5_pluginpathtable = {
NC_FORMATX_NC_HDF5,
NC_PLUGINPATH_DISPATCH_VERSION,
NC4_hdf5_plugin_path_initialize,
Expand All @@ -47,8 +47,6 @@ static const NC_PluginPathDispatch pluginpathtable = {
NC4_hdf5_plugin_path_write
};

const NC_PluginPathDispatch* NC4_hdf5_pluginpathtable = NULL;

/**************************************************/

/**
Expand All @@ -68,8 +66,6 @@ NC4_hdf5_plugin_path_initialize(void** statep, const NClist* initialpaths)
assert(statep != NULL);
if(*statep != NULL) goto done; /* already initialized */

NC4_hdf5_pluginpathtable = &pluginpathtable;

if((g5 = (GlobalHDF5*)calloc(1,sizeof(GlobalHDF5)))==NULL) {stat = NC_ENOMEM; goto done;}
*statep = (void*)g5; g5 = NULL;
done:
Expand Down
6 changes: 1 addition & 5 deletions libnczarr/zplugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static int pluginnamecheck(const char* name);

/**************************************************/
/* The NCZarr Plugin Path Dispatch table and functions */
static const NC_PluginPathDispatch pluginpathtable = {
const NC_PluginPathDispatch NCZ_pluginpathtable = {
NC_FORMATX_NCZARR,
NC_PLUGINPATH_DISPATCH_VERSION,
NCZ_plugin_path_initialize,
Expand All @@ -68,8 +68,6 @@ static const NC_PluginPathDispatch pluginpathtable = {
NCZ_plugin_path_write,
};

const NC_PluginPathDispatch* NCZ_pluginpathtable = NULL;

/**************************************************/
/**
* This function is called as part of nc_initialize.
Expand All @@ -86,8 +84,6 @@ NCZ_plugin_path_initialize(void** statep, const NClist* initialpaths)
assert(statep != NULL);
if(*statep != NULL) goto done; /* already initialized */

NCZ_pluginpathtable = &pluginpathtable;

if((gz = (GlobalNCZarr*)calloc(1,sizeof(GlobalNCZarr)))==NULL) {stat = NC_ENOMEM; goto done;}

gz->pluginpaths = nclistnew();
Expand Down

0 comments on commit 8931d80

Please sign in to comment.