summaryrefslogtreecommitdiffstats
path: root/hl/src/H5TB.c
diff options
context:
space:
mode:
Diffstat (limited to 'hl/src/H5TB.c')
-rw-r--r--hl/src/H5TB.c111
1 files changed, 109 insertions, 2 deletions
diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c
index a1456ea..1ca41a8 100644
--- a/hl/src/H5TB.c
+++ b/hl/src/H5TB.c
@@ -94,6 +94,17 @@ herr_t H5TBmake_table(const char *table_title,
hsize_t i;
herr_t ret_val = -1;
+ /* check the arguments */
+ if (table_title == NULL) {
+ goto out;
+ }
+ if (dset_name == NULL) {
+ goto out;
+ }
+ if (field_names == NULL) {
+ goto out;
+ }
+
dims[0] = nrecords;
dims_chunk[0] = chunk_size;
@@ -290,6 +301,10 @@ herr_t H5TBappend_records(hid_t loc_id,
hsize_t nfields;
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+
/* get the original number of records and fields */
if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0)
goto out;
@@ -360,6 +375,10 @@ herr_t H5TBwrite_records(hid_t loc_id,
hsize_t dims[1];
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+
/* open the dataset. */
if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
@@ -459,6 +478,12 @@ herr_t H5TBwrite_fields_name(hid_t loc_id,
size_t size_native;
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+ if (field_names == NULL)
+ goto out;
+
/* create xfer properties to preserve initialized data */
if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto out;
@@ -616,6 +641,10 @@ herr_t H5TBwrite_fields_index(hid_t loc_id,
char *member_name = NULL;
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+
/* create xfer properties to preserve initialized data */
if((preserve_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
goto out;
@@ -773,6 +802,10 @@ herr_t H5TBread_table(hid_t loc_id,
hsize_t dims[1];
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+
/* open the dataset. */
if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
@@ -846,6 +879,10 @@ herr_t H5TBread_records(hid_t loc_id,
hsize_t nfields;
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+
/* get the number of records and fields */
if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords_orig) < 0)
goto out;
@@ -922,6 +959,13 @@ herr_t H5TBread_fields_name(hid_t loc_id,
hssize_t i, j;
herr_t ret_val = -1;
+
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+ if (field_names == NULL)
+ goto out;
+
/* open the dataset */
if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
@@ -938,7 +982,7 @@ herr_t H5TBread_fields_name(hid_t loc_id,
if((mem_type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
goto out;
- /* iterate tru the members */
+ /* iterate through the members */
for(i = 0, j = 0; i < nfields; i++) {
/* get the member name */
if(NULL == (member_name = H5Tget_member_name(ftype_id, (unsigned)i)))
@@ -984,6 +1028,10 @@ herr_t H5TBread_fields_name(hid_t loc_id,
member_name = NULL;
} /* end for */
+ /* check to make sure field was found, no reason to continue if it does not exist */
+ if(j == 0)
+ goto out;
+
/* get the dataspace handle */
if((sid = H5Dget_space(did)) < 0)
goto out;
@@ -1074,6 +1122,10 @@ herr_t H5TBread_fields_index(hid_t loc_id,
char *member_name = NULL;
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+
/* open the dataset. */
if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
@@ -1231,6 +1283,11 @@ herr_t H5TBdelete_record(hid_t loc_id,
unsigned char *tmp_buf = NULL;
herr_t ret_val = -1;
+
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+
/*-------------------------------------------------------------------------
* first we get information about type size and offsets on disk
*-------------------------------------------------------------------------
@@ -1390,6 +1447,10 @@ herr_t H5TBinsert_record(hid_t loc_id,
unsigned char *tmp_buf = NULL;
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+
/*-------------------------------------------------------------------------
* read the records after the inserted one(s)
*-------------------------------------------------------------------------
@@ -1541,6 +1602,12 @@ herr_t H5TBadd_records_from(hid_t loc_id,
unsigned char *tmp_buf = NULL;
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name1 == NULL)
+ goto out;
+ if (dset_name2 == NULL)
+ goto out;
+
/*-------------------------------------------------------------------------
* first we get information about type size and offsets on disk
*-------------------------------------------------------------------------
@@ -1688,6 +1755,14 @@ herr_t H5TBcombine_tables(hid_t loc_id1,
htri_t has_fill;
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name1 == NULL)
+ goto out;
+ if (dset_name2 == NULL)
+ goto out;
+ if (dset_name3 == NULL)
+ goto out;
+
/*-------------------------------------------------------------------------
* first we get information about type size and offsets on disk
*-------------------------------------------------------------------------
@@ -2043,6 +2118,12 @@ herr_t H5TBinsert_field(hid_t loc_id,
hbool_t inserted;
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+ if (field_name == NULL)
+ goto out;
+
/* get the number of records and fields */
if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
goto out;
@@ -2451,6 +2532,13 @@ herr_t H5TBdelete_field(hid_t loc_id,
htri_t has_fill = FALSE;
herr_t ret_val = -1;
+
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+ if (field_name == NULL)
+ goto out;
+
/* get the number of records and fields */
if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
goto out;
@@ -2859,6 +2947,7 @@ out:
herr_t H5TBAget_title(hid_t loc_id,
char *table_title)
{
+
/* Get the TITLE attribute */
if(H5LT_get_attribute_disk(loc_id, "TITLE", table_title) < 0)
return -1;
@@ -2894,6 +2983,10 @@ htri_t H5TBAget_fill(hid_t loc_id,
htri_t has_fill = FALSE;
htri_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+
/* get the number of records and fields */
if(H5TBget_table_info(loc_id, dset_name, &nfields, &nrecords) < 0)
goto out;
@@ -2962,6 +3055,10 @@ herr_t H5TBget_table_info(hid_t loc_id,
int num_members;
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+
/* open the dataset. */
if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
@@ -3049,6 +3146,10 @@ herr_t H5TBget_field_info(hid_t loc_id,
hssize_t i;
herr_t ret_val = -1;
+ /* check the arguments */
+ if (dset_name == NULL)
+ goto out;
+
/* open the dataset. */
if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
goto out;
@@ -3153,6 +3254,12 @@ hbool_t H5TB_find_field(const char *field, const char *field_list)
const char *start = field_list;
const char *end;
+ /* check the arguments */
+ if (field == NULL)
+ return FALSE;
+ if (field_list == NULL)
+ return FALSE;
+
while((end = HDstrstr(start, ",")) != 0) {
ptrdiff_t count = end - start;
@@ -3161,7 +3268,7 @@ hbool_t H5TB_find_field(const char *field, const char *field_list)
start = end + 1;
} /* end while */
- if(HDstrcmp(start, field) == 0)
+ if(HDstrncmp(start, field, HDstrlen(field)) == 0)
return TRUE;
return FALSE;