diff options
Diffstat (limited to 'src/H5PLplugin_cache.c')
-rw-r--r-- | src/H5PLplugin_cache.c | 89 |
1 files changed, 40 insertions, 49 deletions
diff --git a/src/H5PLplugin_cache.c b/src/H5PLplugin_cache.c index cf3cb9f..85af549 100644 --- a/src/H5PLplugin_cache.c +++ b/src/H5PLplugin_cache.c @@ -26,29 +26,26 @@ /* Module Setup */ /****************/ -#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ - +#include "H5PLmodule.h" /* This source code file is part of the H5PL module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5PLpkg.h" /* Plugin */ -#include "H5Zprivate.h" /* Filter pipeline */ - +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PLpkg.h" /* Plugin */ +#include "H5Zprivate.h" /* Filter pipeline */ /****************/ /* Local Macros */ /****************/ /* Initial capacity of the plugin cache */ -#define H5PL_INITIAL_CACHE_CAPACITY 16 +#define H5PL_INITIAL_CACHE_CAPACITY 16 /* The amount to add to the capacity when the cache is full */ -#define H5PL_CACHE_CAPACITY_ADD 16 - +#define H5PL_CACHE_CAPACITY_ADD 16 /******************/ /* Local Typedefs */ @@ -56,44 +53,38 @@ /* Type for the list of info for opened plugin libraries */ typedef struct H5PL_plugin_t { - H5PL_type_t type; /* Plugin type */ - H5PL_key_t key; /* Unique key to identify the plugin */ - H5PL_HANDLE handle; /* Plugin handle */ + H5PL_type_t type; /* Plugin type */ + H5PL_key_t key; /* Unique key to identify the plugin */ + H5PL_HANDLE handle; /* Plugin handle */ } H5PL_plugin_t; - /********************/ /* Local Prototypes */ /********************/ static herr_t H5PL__expand_cache(void); - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ /* Cache for storing opened plugin libraries */ -static H5PL_plugin_t *H5PL_cache_g = NULL; +static H5PL_plugin_t *H5PL_cache_g = NULL; /* The number of stored plugins */ -static unsigned int H5PL_num_plugins_g = 0; +static unsigned int H5PL_num_plugins_g = 0; /* The capacity of the plugin cache */ -static unsigned int H5PL_cache_capacity_g = 0; +static unsigned int H5PL_cache_capacity_g = 0; - - /*------------------------------------------------------------------------- * Function: H5PL__create_plugin_cache * @@ -107,7 +98,7 @@ static unsigned int H5PL_cache_capacity_g = 0; herr_t H5PL__create_plugin_cache(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -116,7 +107,8 @@ H5PL__create_plugin_cache(void) H5PL_cache_capacity_g = H5PL_INITIAL_CACHE_CAPACITY; - if (NULL == (H5PL_cache_g = (H5PL_plugin_t *)H5MM_calloc((size_t)H5PL_cache_capacity_g * sizeof(H5PL_plugin_t)))) + if (NULL == + (H5PL_cache_g = (H5PL_plugin_t *)H5MM_calloc((size_t)H5PL_cache_capacity_g * sizeof(H5PL_plugin_t)))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for plugin cache") done: @@ -130,7 +122,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__create_plugin_cache() */ - /*------------------------------------------------------------------------- * Function: H5PL__close_plugin_cache * @@ -144,8 +135,8 @@ done: herr_t H5PL__close_plugin_cache(hbool_t *already_closed /*out*/) { - unsigned int u; /* iterator */ - herr_t ret_value = SUCCEED; + unsigned int u; /* iterator */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE_NOERR @@ -157,8 +148,8 @@ H5PL__close_plugin_cache(hbool_t *already_closed /*out*/) H5PL__close((H5PL_cache_g[u]).handle); /* Free the cache array */ - H5PL_cache_g = (H5PL_plugin_t *)H5MM_xfree(H5PL_cache_g); - H5PL_num_plugins_g = 0; + H5PL_cache_g = (H5PL_plugin_t *)H5MM_xfree(H5PL_cache_g); + H5PL_num_plugins_g = 0; H5PL_cache_capacity_g = 0; /* Note that actually closed the table (needed by package close call) */ @@ -170,7 +161,6 @@ H5PL__close_plugin_cache(hbool_t *already_closed /*out*/) FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__close_plugin_cache() */ - /*------------------------------------------------------------------------- * Function: H5PL__expand_cache * @@ -183,7 +173,7 @@ H5PL__close_plugin_cache(hbool_t *already_closed /*out*/) static herr_t H5PL__expand_cache(void) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -191,7 +181,8 @@ H5PL__expand_cache(void) H5PL_cache_capacity_g += H5PL_CACHE_CAPACITY_ADD; /* Resize the array */ - if(NULL == (H5PL_cache_g = (H5PL_plugin_t *)H5MM_realloc(H5PL_cache_g, (size_t)H5PL_cache_capacity_g * sizeof(H5PL_plugin_t)))) + if (NULL == (H5PL_cache_g = (H5PL_plugin_t *)H5MM_realloc(H5PL_cache_g, (size_t)H5PL_cache_capacity_g * + sizeof(H5PL_plugin_t)))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "allocating additional memory for plugin cache failed") /* Initialize the new memory */ @@ -205,7 +196,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__expand_cache() */ - /*------------------------------------------------------------------------- * Function: H5PL__add_plugin * @@ -218,7 +208,7 @@ done: herr_t H5PL__add_plugin(H5PL_type_t type, H5PL_key_t key, H5PL_HANDLE handle) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -228,9 +218,9 @@ H5PL__add_plugin(H5PL_type_t type, H5PL_key_t key, H5PL_HANDLE handle) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't expand plugin cache") /* Store the plugin info and bump the # of plugins */ - H5PL_cache_g[H5PL_num_plugins_g].type = type; - H5PL_cache_g[H5PL_num_plugins_g].key = key; - H5PL_cache_g[H5PL_num_plugins_g].handle = handle; + H5PL_cache_g[H5PL_num_plugins_g].type = type; + H5PL_cache_g[H5PL_num_plugins_g].key = key; + H5PL_cache_g[H5PL_num_plugins_g].handle = handle; H5PL_num_plugins_g++; @@ -238,7 +228,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__add_plugin() */ - /*------------------------------------------------------------------------- * Function: H5PL__find_plugin_in_cache * @@ -255,10 +244,11 @@ done: */ H5_GCC_DIAG_OFF("pedantic") herr_t -H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *found, const void **plugin_info) +H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *found, + const void **plugin_info) { - unsigned int u; /* iterator */ - herr_t ret_value = SUCCEED; + unsigned int u; /* iterator */ + herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -268,20 +258,22 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f HDassert(plugin_info); /* Initialize output parameters */ - *found = FALSE; + *found = FALSE; *plugin_info = NULL; /* Loop over all the plugins, looking for one that matches */ for (u = 0; u < H5PL_num_plugins_g; u++) { /* If the plugin type (filter, etc.) and ID match, query the plugin for its info */ - if ((search_params->type == (H5PL_cache_g[u]).type) && (search_params->key.id == (H5PL_cache_g[u]).key.id)) { + if ((search_params->type == (H5PL_cache_g[u]).type) && + (search_params->key.id == (H5PL_cache_g[u]).key.id)) { - H5PL_get_plugin_info_t get_plugin_info_function; - const H5Z_class2_t *filter_info; + H5PL_get_plugin_info_t get_plugin_info_function; + const H5Z_class2_t * filter_info; /* Get the "get plugin info" function from the plugin. */ - if (NULL == (get_plugin_info_function = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC((H5PL_cache_g[u]).handle, "H5PLget_plugin_info"))) + if (NULL == (get_plugin_info_function = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC( + (H5PL_cache_g[u]).handle, "H5PLget_plugin_info"))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info") /* Call the "get plugin info" function */ @@ -289,7 +281,7 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") /* Set output parameters */ - *found = TRUE; + *found = TRUE; *plugin_info = filter_info; /* No need to continue processing */ @@ -303,4 +295,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__find_plugin_in_cache() */ H5_GCC_DIAG_ON("pedantic") - |