summaryrefslogtreecommitdiffstats
path: root/src/H5Ztrans.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-10-23 20:40:14 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-10-23 20:40:14 (GMT)
commite40557304fcfc662bb1a445abca516ee4b246d94 (patch)
treec9f1692443a62e0c481c7c0278e39d7b83d1b419 /src/H5Ztrans.c
parent1062b4f9d7080a3e439df7d3d527aee43f96d085 (diff)
downloadhdf5-e40557304fcfc662bb1a445abca516ee4b246d94.zip
hdf5-e40557304fcfc662bb1a445abca516ee4b246d94.tar.gz
hdf5-e40557304fcfc662bb1a445abca516ee4b246d94.tar.bz2
[svn-r12803] Description:
Finish new version of the I/O pipeline message, which is much smaller than the previous version. This version is used with the "use the latest version of the format" flag. Closed several memory leaks/overruns (found with valgrind). Also, lots of compiler & formatting cleanups. Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5Ztrans.c')
-rw-r--r--src/H5Ztrans.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c
index 79e69b8..5883058 100644
--- a/src/H5Ztrans.c
+++ b/src/H5Ztrans.c
@@ -908,7 +908,7 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size
FUNC_ENTER_NOAPI(H5Z_xform_eval, FAIL)
- assert(data_xform_prop);
+ HDassert(data_xform_prop);
tree=data_xform_prop->parse_root;
@@ -965,29 +965,24 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size
{
for(i=0; i<data_xform_prop->dat_val_pointers->num_ptrs; i++)
{
- if( (data_xform_prop->dat_val_pointers->ptr_dat_val[i] = (void*)HDmalloc(array_size*H5Tget_size(array_type))) == NULL)
+ if( (data_xform_prop->dat_val_pointers->ptr_dat_val[i] = (void*)H5MM_malloc(array_size*H5Tget_size(array_type))) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "Ran out of memory trying to allocate space for data in data transform")
- HDmemcpy(data_xform_prop->dat_val_pointers->ptr_dat_val[i], array, array_size*H5Tget_size(array_type));
+ HDmemcpy(data_xform_prop->dat_val_pointers->ptr_dat_val[i], array, array_size*H5Tget_size(array_type));
}
}
+
if(H5Z_xform_eval_full(tree, array_size, array_type, &res) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "error while performing data transform")
- else
- {
- HDmemcpy(array, res.value.dat_val, array_size*H5Tget_size(array_type));
+
+ HDmemcpy(array, res.value.dat_val, array_size * H5Tget_size(array_type));
- /* Free the temporary arrays we used */
-
- if(data_xform_prop->dat_val_pointers->num_ptrs > 1)
- {
- for(i=0; i<data_xform_prop->dat_val_pointers->num_ptrs; i++)
- HDfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]);
- }
- }
+ /* Free the temporary arrays we used */
+ if(data_xform_prop->dat_val_pointers->num_ptrs > 1)
+ for(i=0; i<data_xform_prop->dat_val_pointers->num_ptrs; i++)
+ HDfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]);
}
-
done:
if(ret_value < 0)
{
@@ -1375,7 +1370,7 @@ H5Z_xform_create(const char *expr)
if((data_xform_prop = H5MM_calloc(sizeof(H5Z_data_xform_t)))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for data transform info")
- if((data_xform_prop->dat_val_pointers = HDmalloc(sizeof(H5Z_datval_ptrs))) == NULL)
+ if((data_xform_prop->dat_val_pointers = H5MM_malloc(sizeof(H5Z_datval_ptrs))) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for data transform array storage")
/* copy the user's string into the property */
@@ -1393,7 +1388,7 @@ H5Z_xform_create(const char *expr)
* we don't need to allocate any space since no array will have to be
* stored */
if(count > 0)
- if((data_xform_prop->dat_val_pointers->ptr_dat_val = (void**) HDcalloc(count, sizeof(void**))) == NULL)
+ if((data_xform_prop->dat_val_pointers->ptr_dat_val = (void**) H5MM_calloc(count * sizeof(void**))) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for pointers in transform array")
/* Initialize the num_ptrs field, which will be used to keep track of the number of copies
@@ -1515,7 +1510,7 @@ H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop)
if((new_data_xform_prop->xform_exp = H5MM_xstrdup((*data_xform_prop)->xform_exp))==NULL)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for data transform expression")
- if((new_data_xform_prop->dat_val_pointers = HDmalloc(sizeof(H5Z_datval_ptrs))) == NULL)
+ if((new_data_xform_prop->dat_val_pointers = H5MM_malloc(sizeof(H5Z_datval_ptrs))) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for data transform array storage")
/* Find the number of times "x" is used in this equation, and allocate room for storing that many points */
@@ -1526,7 +1521,7 @@ H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop)
}
if(count > 0)
- if((new_data_xform_prop->dat_val_pointers->ptr_dat_val = (void**) HDcalloc(count, sizeof(void**))) == NULL)
+ if((new_data_xform_prop->dat_val_pointers->ptr_dat_val = (void**) H5MM_calloc(count * sizeof(void**))) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for pointers in transform array")
/* Zero out num_pointers prior to H5Z_xform_cop_tree call; that call will increment it to the right amount */