summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2017-11-17 19:59:57 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2017-11-17 19:59:57 (GMT)
commit9599e55176104ab55576ee921be4475e860da5fa (patch)
treec4b83559b363d187398f78e7c053ee33fc35fd8f
parentdfaeaa35cd6b765581d1f0d86076d549135b9500 (diff)
downloadhdf5-9599e55176104ab55576ee921be4475e860da5fa.zip
hdf5-9599e55176104ab55576ee921be4475e860da5fa.tar.gz
hdf5-9599e55176104ab55576ee921be4475e860da5fa.tar.bz2
HDFFV-10328 - remove allocation changes
-rw-r--r--src/H5PLint.c21
-rw-r--r--src/H5PLplugin_cache.c22
-rw-r--r--src/H5Z.c33
3 files changed, 6 insertions, 70 deletions
diff --git a/src/H5PLint.c b/src/H5PLint.c
index 33dda96..c887f86 100644
--- a/src/H5PLint.c
+++ b/src/H5PLint.c
@@ -342,38 +342,19 @@ H5PL__open(const char *path, H5PL_type_t type, int id, hbool_t *success, const v
/* Check if the filter IDs match */
if (info->id == id) {
- H5Z_class2_t *plugin_copy = NULL;
/* Store the plugin in the cache */
if (H5PL__add_plugin(type, id, handle))
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTINSERT, FAIL, "unable to add new plugin to plugin cache")
- /* allocate local copy of plugin info */
- if (NULL == (plugin_copy = (H5Z_class2_t *)H5MM_calloc(sizeof(H5Z_class2_t))))
- HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for plugin info")
- /* Set the plugin info to return */
- *plugin_info = (const void *)info;
-
- plugin_copy->version = info->version;
- plugin_copy->id = info->id;
- plugin_copy->encoder_present = info->encoder_present;
- plugin_copy->decoder_present = info->decoder_present;
- plugin_copy->can_apply = info->can_apply;
- plugin_copy->set_local = info->set_local;
- plugin_copy->filter = info->filter;
- /* copy the user's string into the property */
- if(NULL == (plugin_copy->name = (char *)H5MM_xstrdup(info->name)))
- HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "can't allocate memory for plugin info name")
-
/* Set output parameters */
*success = TRUE;
+ *plugin_info = (const void *)info;
}
}
done:
if (!success && handle)
- if (*plugin_info)
- *plugin_info = (H5Z_class2_t *)H5MM_xfree(*plugin_info);
if (H5PL__close(handle) < 0)
HDONE_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library")
diff --git a/src/H5PLplugin_cache.c b/src/H5PLplugin_cache.c
index ec14159..e483e01 100644
--- a/src/H5PLplugin_cache.c
+++ b/src/H5PLplugin_cache.c
@@ -280,7 +280,6 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f
H5PL_get_plugin_info_t get_plugin_info_function;
const H5Z_class2_t *filter_info;
- H5Z_class2_t *plugin_copy = NULL;
/* 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")))
@@ -290,24 +289,9 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f
if (NULL == (filter_info = (const H5Z_class2_t *)(*get_plugin_info_function)()))
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info")
- if (NULL == (plugin_copy = (H5Z_class2_t *)H5MM_calloc(sizeof(H5Z_class2_t))))
- HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for plugin info")
- /* Set the plugin info to return */
- *plugin_info = plugin_copy;
-
- plugin_copy->version = filter_info->version;
- plugin_copy->id = filter_info->id;
- plugin_copy->encoder_present = filter_info->encoder_present;
- plugin_copy->decoder_present = filter_info->decoder_present;
- plugin_copy->can_apply = filter_info->can_apply;
- plugin_copy->set_local = filter_info->set_local;
- plugin_copy->filter = filter_info->filter;
- /* copy the user's string into the property */
- if(NULL == (plugin_copy->name = (char *)H5MM_xstrdup(filter_info->name)))
- HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "can't allocate memory for plugin info name")
-
/* Set output parameters */
*found = TRUE;
+ *plugin_info = filter_info;
/* No need to continue processing */
break;
@@ -317,10 +301,6 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f
} /* end for */
done:
- /* unallocate local copy of plugin info on failure */
- if (FAIL == ret_value && *plugin_info) {
- *plugin_info = (H5Z_class2_t *)H5MM_xfree(*plugin_info);
- }
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5PL__find_plugin_in_cache() */
#pragma GCC diagnostic pop
diff --git a/src/H5Z.c b/src/H5Z.c
index e7574cd..1f1a905 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -123,7 +123,6 @@ int
H5Z_term_package(void)
{
int n = 0;
- size_t i;
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -131,6 +130,7 @@ H5Z_term_package(void)
#ifdef H5Z_DEBUG
char comment[16], bandwidth[32];
int dir, nprint = 0;
+ size_t i;
if(H5DEBUG(Z)) {
for(i = 0; i < H5Z_table_used_g; i++) {
@@ -179,12 +179,6 @@ H5Z_term_package(void)
} /* end for */
} /* end if */
#endif /* H5Z_DEBUG */
- for (i = 0; i < H5Z_table_used_g; i++) {
- H5Z_class2_t *cls = (H5Z_class2_t *)(H5Z_table_g+i);
- /* deallocate plugin info name */
- if (cls->name)
- cls->name = (char *)H5MM_xfree(cls->name);
- }
/* Free the table of filters */
if(H5Z_table_g) {
H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g);
@@ -325,20 +319,14 @@ H5Z_register (const H5Z_class2_t *cls)
/* Initialize */
i = H5Z_table_used_g++;
HDmemcpy (H5Z_table_g+i, cls, sizeof(H5Z_class2_t));
- H5Z_table_g[i].name = (char *)H5MM_xstrdup(cls->name);
#ifdef H5Z_DEBUG
HDmemset (H5Z_stat_table_g+i, 0, sizeof(H5Z_stats_t));
#endif /* H5Z_DEBUG */
} /* end if */
/* Filter already registered */
else {
- H5Z_class2_t *old_cls = (H5Z_class2_t *)(H5Z_table_g+i);
- /* deallocate plugin info name */
- if (old_cls->name)
- old_cls->name = (char *)H5MM_xfree(old_cls->name);
/* Replace old contents */
- HDmemcpy (old_cls, cls, sizeof(H5Z_class2_t));
- old_cls->name = (char *)H5MM_xstrdup(cls->name);
+ HDmemcpy (H5Z_table_g+i, cls, sizeof(H5Z_class2_t));
} /* end else */
done:
@@ -394,7 +382,6 @@ H5Z_unregister(H5Z_filter_t filter_id)
size_t filter_index; /* Local index variable for filter */
H5Z_object_t object;
herr_t ret_value = SUCCEED; /* Return value */
- H5Z_class2_t *old_cls = NULL;
FUNC_ENTER_NOAPI(FAIL)
@@ -431,10 +418,6 @@ H5Z_unregister(H5Z_filter_t filter_id)
if (H5I_iterate(H5I_FILE, H5Z__flush_file_cb, NULL, FALSE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed")
- /* deallocate plugin info name */
- old_cls = (H5Z_class2_t *)(H5Z_table_g+filter_index);
- if (old_cls->name)
- old_cls->name = (char *)H5MM_xfree(old_cls->name);
/* Remove filter from table */
/* Don't worry about shrinking table size (for now) */
HDmemmove (&H5Z_table_g[filter_index], &H5Z_table_g[filter_index+1], sizeof(H5Z_class2_t)*((H5Z_table_used_g-1)-filter_index));
@@ -658,11 +641,7 @@ H5Z_filter_avail(H5Z_filter_t id)
HGOTO_DONE (TRUE)
if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)id))) {
- herr_t status = H5Z_register(filter_info);
- if (filter_info->name)
- filter_info->name = (char *)H5MM_xfree(filter_info->name);
- filter_info = (H5Z_class2_t *)H5MM_xfree(filter_info);
- if (status < 0)
+ if (H5Z_register (filter_info) < 0)
HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register loaded filter")
HGOTO_DONE (TRUE)
}
@@ -1245,11 +1224,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
/* Try loading the filter */
if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id)))) {
/* Register the filter we loaded */
- herr_t status = H5Z_register(filter_info);
- if (filter_info->name)
- filter_info->name = (char *)H5MM_xfree(filter_info->name);
- filter_info = (H5Z_class2_t *)H5MM_xfree(filter_info);
- if (status < 0)
+ if (H5Z_register(filter_info < 0)
HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
/* Search in the table of registered filters again to find the dynamic filter just loaded and registered */