summaryrefslogtreecommitdiffstats
path: root/hl/src/H5LD.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /hl/src/H5LD.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'hl/src/H5LD.c')
-rw-r--r--hl/src/H5LD.c526
1 files changed, 259 insertions, 267 deletions
diff --git a/hl/src/H5LD.c b/hl/src/H5LD.c
index 21975d1..73043a5 100644
--- a/hl/src/H5LD.c
+++ b/hl/src/H5LD.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* Copyright by The HDF Group. *
-* Copyright by the Board of Trustees of the University of Illinois. *
-* All rights reserved. *
-* *
-* This file is part of HDF5. The full HDF5 copyright notice, including *
-* terms governing use, modification, and redistribution, is contained in *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "H5LDprivate.h"
@@ -22,10 +22,9 @@
static herr_t H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid);
static herr_t H5LD_get_dset_dims(hid_t did, hsize_t *cur_dims);
static size_t H5LD_get_dset_type_size(hid_t did, const char *fields);
-static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims,
- const hsize_t *cur_dims, const char *fields, void *buf);
+static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims,
+ const char *fields, void *buf);
-
/*-------------------------------------------------------------------------
* Function: H5LD_clean_vector
*
@@ -43,30 +42,29 @@ static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims,
void
H5LD_clean_vector(H5LD_memb_t *listv[])
{
- unsigned n; /* Local index variable */
+ unsigned n; /* Local index variable */
HDassert(listv);
/* Go through info for each field stored in listv[] */
- for(n = 0; listv[n] != NULL; n++) {
- if(listv[n]->names) {
- HDfree(listv[n]->names);
- listv[n]->names = NULL;
- } /* end if */
-
- /* Close the type id of the last member in the field */
- if(!(listv[n]->last_tid < 0)) {
- H5Tclose(listv[n]->last_tid);
- listv[n]->last_tid = -1;
- } /* end if */
-
- /* Free the H5LD_memb_t structure for the field */
- HDfree(listv[n]);
- listv[n] = NULL;
+ for (n = 0; listv[n] != NULL; n++) {
+ if (listv[n]->names) {
+ HDfree(listv[n]->names);
+ listv[n]->names = NULL;
+ } /* end if */
+
+ /* Close the type id of the last member in the field */
+ if (!(listv[n]->last_tid < 0)) {
+ H5Tclose(listv[n]->last_tid);
+ listv[n]->last_tid = -1;
+ } /* end if */
+
+ /* Free the H5LD_memb_t structure for the field */
+ HDfree(listv[n]);
+ listv[n] = NULL;
} /* end for */
} /* H5LD_clean_vector() */
-
/*-------------------------------------------------------------------------
* Function: H5LD_construct_info()
*
@@ -85,27 +83,27 @@ H5LD_clean_vector(H5LD_memb_t *listv[])
static herr_t
H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid)
{
- hid_t tmp_tid = -1; /* Dataset type id */
- unsigned i; /* Local index variable */
- herr_t ret_value = FAIL; /* Return value */
+ hid_t tmp_tid = -1; /* Dataset type id */
+ unsigned i; /* Local index variable */
+ herr_t ret_value = FAIL; /* Return value */
/* Make a copy of the incoming datatype */
tmp_tid = H5Tcopy(par_tid);
/* Validate all the members in a field */
- for(i = 0; memb->names[i] != NULL; i++) {
- hid_t memb_tid; /* Type id for a member in a field */
- int idx; /* Index # of a member in a compound datatype */
+ for (i = 0; memb->names[i] != NULL; i++) {
+ hid_t memb_tid; /* Type id for a member in a field */
+ int idx; /* Index # of a member in a compound datatype */
/* Get the member index and member type id */
- if((idx = H5Tget_member_index(tmp_tid, memb->names[i])) < 0)
+ if ((idx = H5Tget_member_index(tmp_tid, memb->names[i])) < 0)
goto done;
- if((memb_tid = H5Tget_member_type(tmp_tid, (unsigned)idx)) < 0)
+ if ((memb_tid = H5Tget_member_type(tmp_tid, (unsigned)idx)) < 0)
goto done;
- /* Sum up the offset of all the members in the field */
+ /* Sum up the offset of all the members in the field */
memb->tot_offset += H5Tget_member_offset(tmp_tid, (unsigned)idx);
- if(H5Tclose(tmp_tid) < 0)
+ if (H5Tclose(tmp_tid) < 0)
goto done;
tmp_tid = memb_tid;
} /* end for */
@@ -121,13 +119,12 @@ H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid)
done:
H5E_BEGIN_TRY
- H5Tclose(tmp_tid);
+ H5Tclose(tmp_tid);
H5E_END_TRY
- return(ret_value);
+ return (ret_value);
} /* H5LD_construct_info() */
-
/*-------------------------------------------------------------------------
* Function: H5LD_construct_vector
*
@@ -153,84 +150,87 @@ done:
*
* Programmer: Vailin Choi; Aug 2010
*
-*-------------------------------------------------------------------------
-*/
+ *-------------------------------------------------------------------------
+ */
int
-H5LD_construct_vector(char *fields, H5LD_memb_t *listv[]/*OUT*/, hid_t par_tid)
+H5LD_construct_vector(char *fields, H5LD_memb_t *listv[] /*OUT*/, hid_t par_tid)
{
- int nfields; /* The # of comma-separated fields in "fields" */
- hbool_t end_of_fields = FALSE; /* end of "fields" */
- char *fields_ptr; /* Pointer to "fields" */
- int ret_value = FAIL; /* Return value */
+ int nfields; /* The # of comma-separated fields in "fields" */
+ hbool_t end_of_fields = FALSE; /* end of "fields" */
+ char * fields_ptr; /* Pointer to "fields" */
+ int ret_value = FAIL; /* Return value */
HDassert(listv);
HDassert(fields);
fields_ptr = fields;
- nfields = 0;
+ nfields = 0;
/* Process till end of "fields" */
- while(!end_of_fields) {
- H5LD_memb_t *memb = NULL; /* Pointer to structure for storing a field's info */
- char *cur; /* Pointer to a member in a field */
- size_t len; /* Estimated # of members in a field */
- hbool_t gotcomma = FALSE; /* A comma encountered */
- hbool_t gotmember = FALSE; /* Getting member in a field */
- hbool_t valid = TRUE; /* Whether a field being processed is valid or not */
- int j = 0; /* The # of members in a field */
-
- len = (HDstrlen(fields_ptr) / 2) + 2;
-
- /* Allocate memory for an H5LD_memb_t for storing a field's info */
- if(NULL == (memb = (H5LD_memb_t *)HDcalloc((size_t)1, sizeof(H5LD_memb_t))))
- goto done;
-
- /* Allocate memory for an array of pointers to member names */
- if(NULL == (memb->names = (char **)HDcalloc(len, sizeof(char *))))
- goto done;
-
- memb->names[j] = fields_ptr;
- memb->last_tid = -1;
- cur = fields_ptr;
-
- /* Continue processing till: not valid or comma encountered or "fields" ended */
- while(valid && !gotcomma && !end_of_fields) {
- switch(*fields_ptr) {
- case '\0': /* end of list */
- if(gotmember) { /* getting something and end of "fields" */
- *cur++ = '\0';;
+ while (!end_of_fields) {
+ H5LD_memb_t *memb = NULL; /* Pointer to structure for storing a field's info */
+ char * cur; /* Pointer to a member in a field */
+ size_t len; /* Estimated # of members in a field */
+ hbool_t gotcomma = FALSE; /* A comma encountered */
+ hbool_t gotmember = FALSE; /* Getting member in a field */
+ hbool_t valid = TRUE; /* Whether a field being processed is valid or not */
+ int j = 0; /* The # of members in a field */
+
+ len = (HDstrlen(fields_ptr) / 2) + 2;
+
+ /* Allocate memory for an H5LD_memb_t for storing a field's info */
+ if (NULL == (memb = (H5LD_memb_t *)HDcalloc((size_t)1, sizeof(H5LD_memb_t))))
+ goto done;
+
+ /* Allocate memory for an array of pointers to member names */
+ if (NULL == (memb->names = (char **)HDcalloc(len, sizeof(char *))))
+ goto done;
+
+ memb->names[j] = fields_ptr;
+ memb->last_tid = -1;
+ cur = fields_ptr;
+
+ /* Continue processing till: not valid or comma encountered or "fields" ended */
+ while (valid && !gotcomma && !end_of_fields) {
+ switch (*fields_ptr) {
+ case '\0': /* end of list */
+ if (gotmember) { /* getting something and end of "fields" */
+ *cur++ = '\0';
+ ;
memb->names[++j] = NULL;
- } /* end if */
+ } /* end if */
else /* getting nothing but end of list */
valid = FALSE;
end_of_fields = TRUE;
break;
- case '\\': /* escape character */
+ case '\\': /* escape character */
++fields_ptr; /* skip it */
- if(*fields_ptr == '\0')
+ if (*fields_ptr == '\0')
valid = FALSE;
else {
- *cur++ = *fields_ptr++;
+ *cur++ = *fields_ptr++;
gotmember = TRUE;
} /* end else */
break;
case '.': /* nested field separator */
- *fields_ptr++ = *cur++ = '\0';;
- if(gotmember) {
+ *fields_ptr++ = *cur++ = '\0';
+ ;
+ if (gotmember) {
memb->names[++j] = cur;
- gotmember = FALSE;
+ gotmember = FALSE;
} /* end if */
else
valid = FALSE;
break;
case ',': /* field separator */
- *fields_ptr++ = *cur++ = '\0';;
- if(gotmember) {
+ *fields_ptr++ = *cur++ = '\0';
+ ;
+ if (gotmember) {
memb->names[++j] = NULL;
- gotmember = FALSE;
+ gotmember = FALSE;
} /* end if */
else
valid = FALSE;
@@ -238,37 +238,36 @@ H5LD_construct_vector(char *fields, H5LD_memb_t *listv[]/*OUT*/, hid_t par_tid)
break;
default:
- *cur++ = *fields_ptr++;
+ *cur++ = *fields_ptr++;
gotmember = TRUE;
break;
- } /* end switch */
- } /* while (valid && !gotcomma && !end_of_fields) */
-
- /* If valid, put into listv and continue processing further info */
- if(valid) {
- listv[nfields++] = memb;
- if(H5LD_construct_info(memb, par_tid) < 0)
- goto done;
- } /* end if */
+ } /* end switch */
+ } /* while (valid && !gotcomma && !end_of_fields) */
+
+ /* If valid, put into listv and continue processing further info */
+ if (valid) {
+ listv[nfields++] = memb;
+ if (H5LD_construct_info(memb, par_tid) < 0)
+ goto done;
+ } /* end if */
else {
- if(memb)
+ if (memb)
HDfree(memb);
- goto done;
- } /* end else */
- } /* while !end_of_fields */
+ goto done;
+ } /* end else */
+ } /* while !end_of_fields */
/* Indicate success */
ret_value = nfields;
done:
listv[nfields] = NULL;
- if(ret_value == FAIL)
- H5LD_clean_vector(listv);
+ if (ret_value == FAIL)
+ H5LD_clean_vector(listv);
- return(ret_value);
-} /* H5LD_construct_vector() */
+ return (ret_value);
+} /* H5LD_construct_vector() */
-
/*-------------------------------------------------------------------------
* Function: H5LD_get_dset_dims
*
@@ -280,38 +279,36 @@ done:
*
* Programmer: Vailin Choi; March 2010
*
-*-------------------------------------------------------------------------
-*/
+ *-------------------------------------------------------------------------
+ */
static herr_t
H5LD_get_dset_dims(hid_t did, hsize_t *cur_dims)
{
- hid_t sid = -1; /* Dataspace ID */
- herr_t ret_value = FAIL; /* Return Value */
+ hid_t sid = -1; /* Dataspace ID */
+ herr_t ret_value = FAIL; /* Return Value */
/* Verify parameter */
- if(cur_dims == NULL)
+ if (cur_dims == NULL)
goto done;
/* Get the dataset's dataspace */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto done;
/* Get the current dimension size */
- if(H5Sget_simple_extent_dims(sid, cur_dims, NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, cur_dims, NULL) < 0)
goto done;
/* Indicate success */
ret_value = SUCCEED;
done:
- H5E_BEGIN_TRY {
- H5Sclose(sid);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { H5Sclose(sid); }
+ H5E_END_TRY;
- return(ret_value);
+ return (ret_value);
} /* H5LD_get_dset_dims() */
-
/*-------------------------------------------------------------------------
* Function: H5LD_get_dset_type_size
*
@@ -330,73 +327,72 @@ done:
static size_t
H5LD_get_dset_type_size(hid_t did, const char *fields)
{
- hid_t dset_tid = -1; /* Dataset's type identifier */
- hid_t tid = -1; /* Native Type identifier */
- H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */
- char *dup_fields = NULL; /* A copy of "fields" */
- size_t ret_value = 0; /* Return value */
+ hid_t dset_tid = -1; /* Dataset's type identifier */
+ hid_t tid = -1; /* Native Type identifier */
+ H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */
+ char * dup_fields = NULL; /* A copy of "fields" */
+ size_t ret_value = 0; /* Return value */
/* Get the datatype of the dataset */
- if((dset_tid = H5Dget_type(did)) < 0)
+ if ((dset_tid = H5Dget_type(did)) < 0)
goto done;
- if((tid = H5Tget_native_type(dset_tid, H5T_DIR_DEFAULT)) < 0)
+ if ((tid = H5Tget_native_type(dset_tid, H5T_DIR_DEFAULT)) < 0)
goto done;
- if(fields == NULL) /* If no "fields" is specified */
+ if (fields == NULL) /* If no "fields" is specified */
ret_value = H5Tget_size(tid);
- else { /* "fields" are specified */
- size_t len; /* Estimate the number of comma-separated fields in "fields" */
- size_t tot = 0; /* Data type size of all the fields in "fields" */
- int n = 0, num = 0; /* Local index variables */
+ else { /* "fields" are specified */
+ size_t len; /* Estimate the number of comma-separated fields in "fields" */
+ size_t tot = 0; /* Data type size of all the fields in "fields" */
+ int n = 0, num = 0; /* Local index variables */
HDassert(fields && *fields);
/* Should be a compound datatype if "fields" exists */
- if(H5Tget_class(dset_tid) != H5T_COMPOUND)
+ if (H5Tget_class(dset_tid) != H5T_COMPOUND)
goto done;
- /* Get a copy of "fields" */
- if(NULL == (dup_fields = HDstrdup(fields)))
+ /* Get a copy of "fields" */
+ if (NULL == (dup_fields = HDstrdup(fields)))
goto done;
- /* Allocate memory for a list of H5LD_memb_t pointers to store "fields" info */
- len = (HDstrlen(fields) / 2) + 2;
- if(NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))))
+ /* Allocate memory for a list of H5LD_memb_t pointers to store "fields" info */
+ len = (HDstrlen(fields) / 2) + 2;
+ if (NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))))
goto done;
- /* Process and store info for "fields" */
- if((num = H5LD_construct_vector(dup_fields, listv/*OUT*/, tid)) < 0)
+ /* Process and store info for "fields" */
+ if ((num = H5LD_construct_vector(dup_fields, listv /*OUT*/, tid)) < 0)
goto done;
- /* Sum up the size of all the datatypes in "fields" */
- for(n = 0; n < num; n++)
- tot += listv[n]->last_tsize;
+ /* Sum up the size of all the datatypes in "fields" */
+ for (n = 0; n < num; n++)
+ tot += listv[n]->last_tsize;
- /* Clean up the vector of H5LD_memb_t structures */
- H5LD_clean_vector(listv);
+ /* Clean up the vector of H5LD_memb_t structures */
+ H5LD_clean_vector(listv);
- /* Return the total size */
- ret_value = tot;
+ /* Return the total size */
+ ret_value = tot;
} /* end else */
done:
H5E_BEGIN_TRY
- H5Tclose(tid);
- H5Tclose(dset_tid);
+ H5Tclose(tid);
+ H5Tclose(dset_tid);
H5E_END_TRY
/* Free the array of H5LD_memb_t pointers */
- if(listv)
+ if (listv)
HDfree(listv);
/* Free memory */
- if(dup_fields)
+ if (dup_fields)
HDfree(dup_fields);
- return(ret_value);
+ return (ret_value);
} /* H5LD_get_dset_type_size() */
-
/*-------------------------------------------------------------------------
* Function: H5LD_get_dset_elmts
*
@@ -410,136 +406,136 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims,
- const char *fields, void *buf)
+H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields,
+ void *buf)
{
- hid_t dtid = -1, tid = -1; /* Dataset type id */
- hid_t sid = -1, mid = -1; /* Dataspace and memory space id */
- hssize_t snum_elmts; /* Number of dataset elements in the selection (signed) */
- hsize_t num_elmts; /* Number of dataset elements in the selection */
- hsize_t start[H5S_MAX_RANK];/* Starting offset */
- hsize_t count[H5S_MAX_RANK];/* ??offset */
- H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */
- char *dup_fields = NULL; /* A copy of "fields" */
- char *sav_buf = NULL; /* Saved pointer temporary buffer */
- unsigned ctr; /* Counter for # of curr_dims > prev_dims */
- int ndims; /* Number of dimensions for the dataset */
- int i; /* Local index variable */
- herr_t ret_value = FAIL; /* Return value */
+ hid_t dtid = -1, tid = -1; /* Dataset type id */
+ hid_t sid = -1, mid = -1; /* Dataspace and memory space id */
+ hssize_t snum_elmts; /* Number of dataset elements in the selection (signed) */
+ hsize_t num_elmts; /* Number of dataset elements in the selection */
+ hsize_t start[H5S_MAX_RANK]; /* Starting offset */
+ hsize_t count[H5S_MAX_RANK]; /* ??offset */
+ H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */
+ char * dup_fields = NULL; /* A copy of "fields" */
+ char * sav_buf = NULL; /* Saved pointer temporary buffer */
+ unsigned ctr; /* Counter for # of curr_dims > prev_dims */
+ int ndims; /* Number of dimensions for the dataset */
+ int i; /* Local index variable */
+ herr_t ret_value = FAIL; /* Return value */
/* Verify parameters */
- if(prev_dims == NULL || cur_dims == NULL || buf == NULL)
- goto done;
+ if (prev_dims == NULL || cur_dims == NULL || buf == NULL)
+ goto done;
/* Get dataset's dataspace */
- if((sid = H5Dget_space(did)) < 0)
- goto done;
+ if ((sid = H5Dget_space(did)) < 0)
+ goto done;
/* Get the number of dimensions */
- if((ndims = H5Sget_simple_extent_ndims(sid)) < 0)
- goto done;
+ if ((ndims = H5Sget_simple_extent_ndims(sid)) < 0)
+ goto done;
/* Verify that cur_dims must have one dimension whose size is greater than prev_dims */
HDmemset(start, 0, sizeof start);
HDmemset(count, 0, sizeof count);
ctr = 0;
- for(i = 0; i < ndims; i++)
- if(cur_dims[i] > prev_dims[i]) {
- ++ctr;
- count[i] = cur_dims[i] - prev_dims[i];
- start[i] = prev_dims[i];
- } /* end if */
+ for (i = 0; i < ndims; i++)
+ if (cur_dims[i] > prev_dims[i]) {
+ ++ctr;
+ count[i] = cur_dims[i] - prev_dims[i];
+ start[i] = prev_dims[i];
+ } /* end if */
else { /* < or = */
- start[i] = 0;
- count[i] = MIN(prev_dims[i], cur_dims[i]);
- } /* end else */
- if(!ctr)
- goto done;
-
- if(ctr == 1) { /* changes for only one dimension */
- /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */
- if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
- goto done;
- } /* end if */
+ start[i] = 0;
+ count[i] = MIN(prev_dims[i], cur_dims[i]);
+ } /* end else */
+ if (!ctr)
+ goto done;
+
+ if (ctr == 1) { /* changes for only one dimension */
+ /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */
+ if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
+ goto done;
+ } /* end if */
else { /* changes for more than one dimensions */
- HDmemset(start, 0, sizeof start);
+ HDmemset(start, 0, sizeof start);
- /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */
- if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, cur_dims, NULL) < 0)
- goto done;
- if(H5Sselect_hyperslab(sid, H5S_SELECT_NOTB, start, NULL, prev_dims, NULL) < 0)
- goto done;
+ /* Make the selection in the dataset based on "cur_dims" and "prev_dims" */
+ if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, cur_dims, NULL) < 0)
+ goto done;
+ if (H5Sselect_hyperslab(sid, H5S_SELECT_NOTB, start, NULL, prev_dims, NULL) < 0)
+ goto done;
} /* end else */
/* Get the number of elements in the selection */
- if(0 == (snum_elmts = H5Sget_select_npoints(sid)))
+ if (0 == (snum_elmts = H5Sget_select_npoints(sid)))
goto done;
num_elmts = (hsize_t)snum_elmts;
/* Create the memory space for the selection */
- if((mid = H5Screate_simple(1, &num_elmts, NULL)) < 0)
- goto done;
+ if ((mid = H5Screate_simple(1, &num_elmts, NULL)) < 0)
+ goto done;
/* Get the native datatype size */
- if((dtid = H5Dget_type(did)) < 0)
+ if ((dtid = H5Dget_type(did)) < 0)
goto done;
- if((tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0)
+ if ((tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0)
goto done;
- if(fields == NULL) { /* nothing in "fields" */
- /* Read and store all the elements in "buf" */
- if(H5Dread(did, tid, mid, sid, H5P_DEFAULT, buf) < 0)
- goto done;
- } /* end if */
- else { /* "fields" is specified */
- unsigned char *buf_p = (unsigned char *)buf; /* Pointer to the destination buffer */
- char *tmp_buf; /* Temporary buffer for data read */
- size_t tot_tsize; /* Total datatype size */
- size_t len; /* Estimate the number of comma-separated fields in "fields" */
-
- /* should be a compound datatype if "fields" exists */
- if(H5Tget_class(tid) != H5T_COMPOUND)
- goto done;
-
- /* Get the total size of the dataset's datatypes */
- if(0 == (tot_tsize = H5LD_get_dset_type_size(did, NULL)))
- goto done;
-
- /* Allocate memory for reading in the elements in the dataset selection */
- if(NULL == (sav_buf = tmp_buf = (char *)HDcalloc((size_t)num_elmts, tot_tsize)))
- goto done;
-
- /* Read the dataset elements in the selection */
- if(H5Dread(did, tid, mid, sid, H5P_DEFAULT, tmp_buf) < 0)
- goto done;
-
- /* Make a copy of "fields" */
- if(NULL == (dup_fields = HDstrdup(fields)))
- goto done;
-
- /* Allocate memory for the vector of H5LD_memb_t pointers */
- len = (HDstrlen(fields) / 2) + 2;
- if(NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))))
- goto done;
-
- /* Process and store information for "fields" */
- if(H5LD_construct_vector(dup_fields, listv, tid) < 0)
+ if (fields == NULL) { /* nothing in "fields" */
+ /* Read and store all the elements in "buf" */
+ if (H5Dread(did, tid, mid, sid, H5P_DEFAULT, buf) < 0)
+ goto done;
+ } /* end if */
+ else { /* "fields" is specified */
+ unsigned char *buf_p = (unsigned char *)buf; /* Pointer to the destination buffer */
+ char * tmp_buf; /* Temporary buffer for data read */
+ size_t tot_tsize; /* Total datatype size */
+ size_t len; /* Estimate the number of comma-separated fields in "fields" */
+
+ /* should be a compound datatype if "fields" exists */
+ if (H5Tget_class(tid) != H5T_COMPOUND)
goto done;
- /* Copy data for each dataset element in the selection */
- for(i = 0; i < (int)num_elmts; i++) {
- int j; /* Local index variable */
+ /* Get the total size of the dataset's datatypes */
+ if (0 == (tot_tsize = H5LD_get_dset_type_size(did, NULL)))
+ goto done;
- /* Copy data for "fields" to the input buffer */
- for(j = 0; listv[j] != NULL; j++) {
- HDmemcpy(buf_p, tmp_buf + listv[j]->tot_offset, listv[j]->last_tsize);
- buf_p += listv[j]->last_tsize;
- } /* end for */
- tmp_buf += tot_tsize;
- } /* end for */
+ /* Allocate memory for reading in the elements in the dataset selection */
+ if (NULL == (sav_buf = tmp_buf = (char *)HDcalloc((size_t)num_elmts, tot_tsize)))
+ goto done;
+
+ /* Read the dataset elements in the selection */
+ if (H5Dread(did, tid, mid, sid, H5P_DEFAULT, tmp_buf) < 0)
+ goto done;
+
+ /* Make a copy of "fields" */
+ if (NULL == (dup_fields = HDstrdup(fields)))
+ goto done;
- /* Clean up the vector of H5LD_memb_t structures */
- H5LD_clean_vector(listv);
+ /* Allocate memory for the vector of H5LD_memb_t pointers */
+ len = (HDstrlen(fields) / 2) + 2;
+ if (NULL == (listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))))
+ goto done;
+
+ /* Process and store information for "fields" */
+ if (H5LD_construct_vector(dup_fields, listv, tid) < 0)
+ goto done;
+
+ /* Copy data for each dataset element in the selection */
+ for (i = 0; i < (int)num_elmts; i++) {
+ int j; /* Local index variable */
+
+ /* Copy data for "fields" to the input buffer */
+ for (j = 0; listv[j] != NULL; j++) {
+ HDmemcpy(buf_p, tmp_buf + listv[j]->tot_offset, listv[j]->last_tsize);
+ buf_p += listv[j]->last_tsize;
+ } /* end for */
+ tmp_buf += tot_tsize;
+ } /* end for */
+
+ /* Clean up the vector of H5LD_memb_t structures */
+ H5LD_clean_vector(listv);
} /* end else */
/* Indicate success */
@@ -547,23 +543,23 @@ H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims
done:
H5E_BEGIN_TRY
- H5Tclose(dtid);
- H5Tclose(tid);
- H5Sclose(sid);
- H5Sclose(mid);
+ H5Tclose(dtid);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Sclose(mid);
H5E_END_TRY
/* Free the array of H5LD_memb_t pointers */
- if(listv)
+ if (listv)
HDfree(listv);
/* Free memory */
- if(dup_fields)
+ if (dup_fields)
HDfree(dup_fields);
- if(sav_buf)
+ if (sav_buf)
HDfree(sav_buf);
- return(ret_value);
+ return (ret_value);
} /* H5LD_get_dset_elmts() */
/*-------------------------------------------------------------------------
@@ -573,7 +569,6 @@ done:
*-------------------------------------------------------------------------
*/
-
/*-------------------------------------------------------------------------
* Function: H5LDget_dset_dims
*
@@ -589,11 +584,9 @@ done:
herr_t
H5LDget_dset_dims(hid_t did, hsize_t *cur_dims)
{
- return(H5LD_get_dset_dims(did, cur_dims));
+ return (H5LD_get_dset_dims(did, cur_dims));
} /* H5LDget_dset_dims() */
-
-
/*-------------------------------------------------------------------------
* Function: H5LDget_dset_type_size
*
@@ -609,10 +602,9 @@ H5LDget_dset_dims(hid_t did, hsize_t *cur_dims)
size_t
H5LDget_dset_type_size(hid_t did, const char *fields)
{
- return(H5LD_get_dset_type_size(did, fields));
+ return (H5LD_get_dset_type_size(did, fields));
} /* H5LDget_dset_type_size() */
-
/*-------------------------------------------------------------------------
* Function: H5LDget_dset_elmts
*
@@ -626,8 +618,8 @@ H5LDget_dset_type_size(hid_t did, const char *fields)
*-------------------------------------------------------------------------
*/
herr_t
-H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, void *buf)
+H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields,
+ void *buf)
{
- return(H5LD_get_dset_elmts(did, prev_dims, cur_dims, fields, buf) );
+ return (H5LD_get_dset_elmts(did, prev_dims, cur_dims, fields, buf));
} /* H5LDget_dset_elmts() */
-