diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2013-10-31 04:20:36 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2013-10-31 04:20:36 (GMT) |
commit | e6cace9ee46e903a8612aba7d9d1d72fa0968217 (patch) | |
tree | ac7d07ea06d3d5ac73e34bc54ff17620a4d083fe /hl/src | |
parent | 2eb24b16dac78b3e27769c20502299475fb8dde6 (diff) | |
download | hdf5-e6cace9ee46e903a8612aba7d9d1d72fa0968217.zip hdf5-e6cace9ee46e903a8612aba7d9d1d72fa0968217.tar.gz hdf5-e6cace9ee46e903a8612aba7d9d1d72fa0968217.tar.bz2 |
[svn-r24376] Updated all code to use HDmalloc, HDcalloc, and HDfree.
Prep work for adding a memory free function, part of HDFFV-8551.
Tested on:
32-bit LE linux (jam)
* with C++, Fortran
* with thread safety on
These are minor changes (almost entirely renaming foo functions
to HDfoo) that don't change functionality. This should not
require a full commit test.
Diffstat (limited to 'hl/src')
-rw-r--r-- | hl/src/H5DS.c | 94 | ||||
-rw-r--r-- | hl/src/H5HLprivate2.h | 40 | ||||
-rw-r--r-- | hl/src/H5IM.c | 12 | ||||
-rw-r--r-- | hl/src/H5LT.c | 5 | ||||
-rw-r--r-- | hl/src/H5PT.c | 36 | ||||
-rw-r--r-- | hl/src/H5TB.c | 118 | ||||
-rw-r--r-- | hl/src/hdf5_hl.h | 2 |
7 files changed, 144 insertions, 163 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 5f8cd50..06ce078 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -254,7 +254,7 @@ herr_t H5DSattach_scale(hid_t did, goto out; /* allocate and initialize the VL */ - buf = (hvl_t *)malloc((size_t)rank * sizeof(hvl_t)); + buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); if(buf == NULL) goto out; @@ -265,7 +265,7 @@ herr_t H5DSattach_scale(hid_t did, /* store the REF information in the index of the dataset that has the DS */ buf[idx].len = 1; - buf[idx].p = malloc( 1 * sizeof(hobj_ref_t)); + buf[idx].p = HDmalloc( 1 * sizeof(hobj_ref_t)); ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds; /* write the attribute with the reference */ @@ -282,7 +282,7 @@ herr_t H5DSattach_scale(hid_t did, if(H5Aclose(aid) < 0) goto out; - free(buf); + HDfree(buf); buf = NULL; } @@ -303,7 +303,7 @@ herr_t H5DSattach_scale(hid_t did, goto out; /* allocate and initialize the VL */ - buf = (hvl_t *)malloc((size_t)rank * sizeof(hvl_t)); + buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); if(buf == NULL) goto out; @@ -343,13 +343,13 @@ herr_t H5DSattach_scale(hid_t did, if(buf[idx].len > 0) { buf[idx].len++; len = buf[idx].len; - buf[idx].p = realloc(buf[idx].p, len * sizeof(hobj_ref_t)); + buf[idx].p = HDrealloc(buf[idx].p, len * sizeof(hobj_ref_t)); ((hobj_ref_t *)buf[idx].p)[len - 1] = ref_to_ds; } /* end if */ else { /* store the REF information in the index of the dataset that has the DS */ buf[idx].len = 1; - buf[idx].p = malloc(sizeof(hobj_ref_t)); + buf[idx].p = HDmalloc(sizeof(hobj_ref_t)); ((hobj_ref_t *)buf[idx].p)[0] = ref_to_ds; } /* end else */ } /* end if */ @@ -367,7 +367,7 @@ herr_t H5DSattach_scale(hid_t did, goto out; if(H5Aclose(aid) < 0) goto out; - free(buf); + HDfree(buf); buf = NULL; } /* has_dimlist */ @@ -447,7 +447,7 @@ herr_t H5DSattach_scale(hid_t did, nelmts++; - dsbuf = (ds_list_t*) malloc((size_t)nelmts * sizeof(ds_list_t)); + dsbuf = (ds_list_t*) HDmalloc((size_t)nelmts * sizeof(ds_list_t)); if(dsbuf == NULL) goto out; @@ -497,7 +497,7 @@ herr_t H5DSattach_scale(hid_t did, if (H5Tclose(ntid) < 0) goto out; - free(dsbuf); + HDfree(dsbuf); dsbuf = NULL; } /* has_reflist */ @@ -519,9 +519,9 @@ herr_t H5DSattach_scale(hid_t did, /* error zone */ out: if(buf) - free(buf); + HDfree(buf); if(dsbuf) - free(dsbuf); + HDfree(dsbuf); H5E_BEGIN_TRY { H5Sclose(sid); @@ -673,7 +673,7 @@ herr_t H5DSdetach_scale(hid_t did, goto out; /* allocate and initialize the VL */ - buf = (hvl_t *)malloc((size_t)rank * sizeof(hvl_t)); + buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); if(buf == NULL) goto out; @@ -718,7 +718,7 @@ herr_t H5DSdetach_scale(hid_t did, ((hobj_ref_t *)buf[idx].p)[j] = ((hobj_ref_t *)buf[idx].p)[len-1]; len = --buf[idx].len; if(len == 0) { - free(buf[idx].p); + HDfree(buf[idx].p); buf[idx].p = NULL; } /* Since a reference to a dim. scale can be inserted only once, @@ -760,7 +760,7 @@ herr_t H5DSdetach_scale(hid_t did, if(H5Aclose(aid) < 0) goto out; - free(buf); + HDfree(buf); buf = NULL; @@ -786,7 +786,7 @@ herr_t H5DSdetach_scale(hid_t did, if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) goto out; - dsbuf = (ds_list_t*) malloc((size_t)nelmts * sizeof(ds_list_t)); + dsbuf = (ds_list_t*) HDmalloc((size_t)nelmts * sizeof(ds_list_t)); if(dsbuf == NULL) goto out; @@ -876,7 +876,7 @@ herr_t H5DSdetach_scale(hid_t did, if (H5Tclose(ntid) < 0) goto out; - free(dsbuf); + HDfree(dsbuf); dsbuf = NULL; return SUCCEED; @@ -890,7 +890,7 @@ out: H5Tclose(tid); if(dsbuf) { - free(dsbuf); + HDfree(dsbuf); dsbuf = NULL; } if(buf) { @@ -898,9 +898,9 @@ out: free the pointers allocated when we read data in */ for(i = 0; i < rank; i++) { if(buf[i].p) - free(buf[i].p); + HDfree(buf[i].p); } - free(buf); + HDfree(buf); buf = NULL; } } H5E_END_TRY; @@ -1033,7 +1033,7 @@ htri_t H5DSis_attached(hid_t did, goto out; /* allocate and initialize the VL */ - buf = (hvl_t*)malloc((size_t)rank * sizeof(hvl_t)); + buf = (hvl_t*)HDmalloc((size_t)rank * sizeof(hvl_t)); if(buf == NULL) goto out; @@ -1079,7 +1079,7 @@ htri_t H5DSis_attached(hid_t did, goto out; if (H5Aclose(aid) < 0) goto out; - free(buf); + HDfree(buf); buf = NULL; } /* has_dimlist */ @@ -1116,7 +1116,7 @@ htri_t H5DSis_attached(hid_t did, if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0) goto out; - dsbuf = (ds_list_t*) malloc((size_t)nelmts * sizeof(ds_list_t)); + dsbuf = (ds_list_t*) HDmalloc((size_t)nelmts * sizeof(ds_list_t)); if (dsbuf == NULL) goto out; @@ -1170,7 +1170,7 @@ htri_t H5DSis_attached(hid_t did, if (H5Aclose(aid) < 0) goto out; - free(dsbuf); + HDfree(dsbuf); dsbuf = NULL; } /* has_reflist */ @@ -1189,11 +1189,11 @@ out: } H5E_END_TRY; if (buf) { - free(buf); + HDfree(buf); buf = NULL; } if(dsbuf) { - free(dsbuf); + HDfree(dsbuf); dsbuf = NULL; } return FAIL; @@ -1317,7 +1317,7 @@ herr_t H5DSiterate_scales(hid_t did, goto out; /* allocate and initialize the VL */ - buf = (hvl_t*)malloc((size_t)rank * sizeof(hvl_t)); + buf = (hvl_t*)HDmalloc((size_t)rank * sizeof(hvl_t)); if(buf == NULL) goto out; @@ -1380,7 +1380,7 @@ herr_t H5DSiterate_scales(hid_t did, if (H5Aclose(aid) < 0) goto out; - free(buf); + HDfree(buf); buf = NULL; } /* if has_dimlist */ @@ -1390,7 +1390,7 @@ out: H5E_BEGIN_TRY { if(buf) { H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf); - free(buf); + HDfree(buf); } H5Sclose(sid); H5Aclose(aid); @@ -1489,7 +1489,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; /* allocate and initialize */ - buf = (const char **) malloc((size_t) rank * sizeof(char *)); + buf = (const char **) HDmalloc((size_t) rank * sizeof(char *)); if (buf == NULL) goto out; @@ -1513,7 +1513,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; if (buf) { - free(buf); + HDfree(buf); buf = NULL; } } @@ -1532,7 +1532,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; /* allocate and initialize */ - buf = (const char **) malloc((size_t) rank * sizeof(char *)); + buf = (const char **) HDmalloc((size_t) rank * sizeof(char *)); if (buf == NULL) goto out; @@ -1543,7 +1543,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) /* free the ptr that will be replaced by label */ if (buf[idx]) - free((void *)buf[idx]); + HDfree((void *)buf[idx]); /* store the label information in the required index */ buf[idx] = label; @@ -1559,7 +1559,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) for (i = 0; i < (unsigned int) rank; i++) { if (buf[i]) - free((void *)buf[i]); + HDfree((void *)buf[i]); } /* close */ @@ -1569,7 +1569,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) goto out; if (buf) { - free(buf); + HDfree(buf); buf = NULL; } } @@ -1586,9 +1586,9 @@ out: for (i = 0; i < (unsigned int) rank; i++) { if (buf[i]) - free((void *)buf[i]); + HDfree((void *)buf[i]); } - free(buf); + HDfree(buf); } H5E_BEGIN_TRY { @@ -1692,7 +1692,7 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) goto out; /* allocate and initialize */ - buf = (char **) malloc((size_t) rank * sizeof(char *)); + buf = (char **) HDmalloc((size_t) rank * sizeof(char *)); if (buf == NULL) goto out; @@ -1724,7 +1724,7 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) for (i = 0; i < rank; i++) { if (buf[i]) - free(buf[i]); + HDfree(buf[i]); } /* close */ @@ -1734,7 +1734,7 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) goto out; if (buf) { - free(buf); + HDfree(buf); buf = NULL; } @@ -1748,9 +1748,9 @@ out: for (i = 0; i < rank; i++) { if (buf[i]) - free(buf[i]); + HDfree(buf[i]); } - free(buf); + HDfree(buf); } H5E_BEGIN_TRY { @@ -1845,7 +1845,7 @@ ssize_t H5DSget_scale_name(hid_t did, goto out; /* allocate a temporary buffer */ - buf = (char*)malloc(nbytes * sizeof(char)); + buf = (char*)HDmalloc(nbytes * sizeof(char)); if (buf == NULL) goto out; @@ -1872,7 +1872,7 @@ ssize_t H5DSget_scale_name(hid_t did, if (H5Sclose(sid) < 0) goto out; if (buf) - free(buf); + HDfree(buf); return (ssize_t)(nbytes - 1); @@ -1884,7 +1884,7 @@ out: H5Sclose(sid); } H5E_END_TRY; if (buf) - free(buf); + HDfree(buf); return FAIL; } @@ -2052,7 +2052,7 @@ int H5DSget_num_scales(hid_t did, goto out; /* allocate and initialize the VL */ - buf = (hvl_t *)malloc((size_t)rank * sizeof(hvl_t)); + buf = (hvl_t *)HDmalloc((size_t)rank * sizeof(hvl_t)); if(buf == NULL) goto out; @@ -2071,7 +2071,7 @@ int H5DSget_num_scales(hid_t did, goto out; if(H5Aclose(aid) < 0) goto out; - free(buf); + HDfree(buf); buf = NULL; } /* has_dimlist */ @@ -2086,7 +2086,7 @@ out: } H5E_END_TRY; if(buf) - free(buf); + HDfree(buf); return FAIL; } diff --git a/hl/src/H5HLprivate2.h b/hl/src/H5HLprivate2.h index e2597db..1b67c70 100644 --- a/hl/src/H5HLprivate2.h +++ b/hl/src/H5HLprivate2.h @@ -22,44 +22,8 @@ /* Public High-Level header */ #include "hdf5_hl.h" -/* The following is copied from src/H5private.h */ - -/* - * Status return values for the `herr_t' type. - * Since some unix/c routines use 0 and -1 (or more precisely, non-negative - * vs. negative) as their return code, and some assumption had been made in - * the code about that, it is important to keep these constants the same - * values. When checking the success or failure of an integer-valued - * function, remember to compare against zero and not one of these two - * values. - */ -#define SUCCEED 0 -#define FAIL (-1) -#define UFAIL (unsigned)(-1) - -/* minimum of two, three, or four values */ -#undef MIN -#define MIN(a,b) (((a)<(b)) ? (a) : (b)) -#define MIN2(a,b) MIN(a,b) -#define MIN3(a,b,c) MIN(a,MIN(b,c)) -#define MIN4(a,b,c,d) MIN(MIN(a,b),MIN(c,d)) - -/* maximum of two, three, or four values */ -#undef MAX -#define MAX(a,b) (((a)>(b)) ? (a) : (b)) -#define MAX2(a,b) MAX(a,b) -#define MAX3(a,b,c) MAX(a,MAX(b,c)) -#define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d)) - -/* - * HDF Boolean type. - */ -#ifndef FALSE -# define FALSE 0 -#endif -#ifndef TRUE -# define TRUE 1 -#endif +/* HDF5 private functions */ +#include "H5private.h" #endif /* _H5HLprivate2_H */ diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c index e55aaf8..9c7c7e8 100644 --- a/hl/src/H5IM.c +++ b/hl/src/H5IM.c @@ -594,7 +594,7 @@ herr_t H5IMlink_palette( hid_t loc_id, dim_ref = n_refs + 1; - refbuf = (hobj_ref_t*)malloc( sizeof(hobj_ref_t) * (int)dim_ref ); + refbuf = (hobj_ref_t*)HDmalloc( sizeof(hobj_ref_t) * (int)dim_ref ); if ( H5Aread( aid, atid, refbuf ) < 0) goto out; @@ -635,7 +635,7 @@ herr_t H5IMlink_palette( hid_t loc_id, if(H5Aclose(aid) < 0) goto out; - free( refbuf ); + HDfree( refbuf ); } /* ok_pal == 1 */ @@ -901,7 +901,7 @@ herr_t H5IMget_palette_info( hid_t loc_id, dim_ref = n_refs; - refbuf = (hobj_ref_t*)malloc( sizeof(hobj_ref_t) * (int)dim_ref ); + refbuf = (hobj_ref_t*)HDmalloc( sizeof(hobj_ref_t) * (int)dim_ref ); if ( H5Aread( aid, atid, refbuf ) < 0) goto out; @@ -930,7 +930,7 @@ herr_t H5IMget_palette_info( hid_t loc_id, goto out; if ( H5Aclose( aid ) < 0) goto out; - free( refbuf ); + HDfree( refbuf ); } @@ -1012,7 +1012,7 @@ herr_t H5IMget_palette( hid_t loc_id, dim_ref = n_refs; - refbuf = (hobj_ref_t*)malloc( sizeof(hobj_ref_t) * (int)dim_ref ); + refbuf = (hobj_ref_t*)HDmalloc( sizeof(hobj_ref_t) * (int)dim_ref ); if ( H5Aread( aid, atid, refbuf ) < 0) goto out; @@ -1034,7 +1034,7 @@ herr_t H5IMget_palette( hid_t loc_id, goto out; if ( H5Aclose( aid ) < 0) goto out; - free( refbuf ); + HDfree( refbuf ); } /* Close the image dataset. */ diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 98f2ff2..d175099 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -13,13 +13,12 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include <string.h> -#include <stdlib.h> #include <assert.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> #include "H5LTprivate.h" -#include "H5private.h" /* For Lex and Yacc */ #define COL 3 diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index 92b041a..071ae20 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -13,9 +13,12 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include <stdlib.h> + #include "H5PTprivate.h" #include "H5TBprivate.h" -#include <stdlib.h> + +#define HDfree(X) free(X) /* Packet Table private data */ @@ -33,6 +36,7 @@ static H5I_type_t H5PT_ptable_id_type = H5I_UNINIT; #define H5PT_HASH_TABLE_SIZE 64 /* Packet Table private functions */ +static herr_t H5PT_free_id(void *id); static herr_t H5PT_close( htbl_t* table ); static herr_t H5PT_create_index(htbl_t *table_id); static herr_t H5PT_set_index(htbl_t *table_id, hsize_t pt_index); @@ -84,11 +88,11 @@ hid_t H5PTcreate_fl ( hid_t loc_id, /* Register the packet table ID type if this is the first table created */ if(H5PT_ptable_id_type < 0) - if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)free)) < 0) + if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) goto out; /* Get memory for the table identifier */ - table = (htbl_t *)malloc(sizeof(htbl_t)); + table = (htbl_t *)HDmalloc(sizeof(htbl_t)); /* Create a simple data space with unlimited size */ dims[0] = 0; @@ -142,7 +146,7 @@ hid_t H5PTcreate_fl ( hid_t loc_id, H5Pclose(plist_id); H5Dclose(dset_id); if(table) - free(table); + HDfree(table); H5E_END_TRY return H5I_INVALID_HID; } @@ -232,10 +236,10 @@ hid_t H5PTopen( hid_t loc_id, /* Register the packet table ID type if this is the first table created */ if( H5PT_ptable_id_type < 0) - if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)free)) < 0) + if((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) goto out; - table = (htbl_t *)malloc(sizeof(htbl_t)); + table = (htbl_t *)HDmalloc(sizeof(htbl_t)); if ( table == NULL ) { goto out; @@ -291,12 +295,26 @@ out: { H5Dclose(table->dset_id); H5Tclose(table->type_id); - free(table); + HDfree(table); } H5E_END_TRY return H5I_INVALID_HID; } +/*------------------------------------------------------------------------- + * Function: H5PT_free_id + * + * Purpose: Free an id. Callback for H5Iregister_type. + * + * Return: Success: 0, Failure: N/A + *------------------------------------------------------------------------- + */ +static herr_t +H5PT_free_id(void *id) +{ + HDfree(id); + return 0; +} /*------------------------------------------------------------------------- * Function: H5PT_close @@ -331,7 +349,7 @@ H5PT_close( htbl_t* table) if(H5Tclose(table->type_id) < 0) goto out; - free(table); + HDfree(table); return 0; @@ -342,7 +360,7 @@ out: H5Dclose(table->dset_id); H5Tclose(table->type_id); H5E_END_TRY - free(table); + HDfree(table); } return -1; } diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index 0b6305b..1547e00 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -15,7 +15,7 @@ #include <stdlib.h> #include <string.h> -#include "H5private.h" + #include "H5LTprivate.h" #include "H5TBprivate.h" @@ -196,7 +196,7 @@ herr_t H5TBmake_table( const char *table_title, if (H5LTset_attribute_string( loc_id, dset_name, attr_name, member_name ) < 0) goto out; - free( member_name ); + HDfree( member_name ); } @@ -234,7 +234,7 @@ herr_t H5TBmake_table( const char *table_title, if (H5Aclose(attr_id) < 0) goto out; - free(member_name); + HDfree(member_name); } /* terminate access to the data space. */ @@ -570,7 +570,7 @@ herr_t H5TBwrite_fields_name( hid_t loc_id, goto out; } - free( member_name ); + HDfree( member_name ); } @@ -734,7 +734,7 @@ herr_t H5TBwrite_fields_index( hid_t loc_id, if(H5Tclose( nmtype_id ) < 0) goto out; - free( member_name ); + HDfree( member_name ); } @@ -1059,7 +1059,7 @@ herr_t H5TBread_fields_name( hid_t loc_id, goto out; j++; } - free( member_name ); + HDfree( member_name ); } /* get the dataspace handle */ @@ -1221,7 +1221,7 @@ herr_t H5TBread_fields_index( hid_t loc_id, if (H5Tclose( nmtype_id ) < 0) goto out; - free( member_name ); + HDfree( member_name ); } /* get the dataspace handle */ @@ -1328,9 +1328,9 @@ herr_t H5TBdelete_record( hid_t loc_id, if (H5TBget_table_info ( loc_id, dset_name, &nfields, &ntotal_records ) < 0) goto out; - if(NULL == (src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t)))) + if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; - if(NULL == (src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t)))) + if(NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; /* get field info */ @@ -1351,7 +1351,7 @@ herr_t H5TBdelete_record( hid_t loc_id, if ( read_nrecords ) { - if(NULL == (tmp_buf = (unsigned char *)calloc((size_t) read_nrecords, src_size ))) + if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t) read_nrecords, src_size ))) goto out; /* read the records after the deleted one(s) */ @@ -1415,22 +1415,22 @@ herr_t H5TBdelete_record( hid_t loc_id, goto out; if(tmp_buf) - free(tmp_buf); + HDfree(tmp_buf); if(src_offset) - free(src_offset); + HDfree(src_offset); if(src_sizes) - free(src_sizes); + HDfree(src_sizes); return 0; /* error zone */ out: if(tmp_buf) - free(tmp_buf); + HDfree(tmp_buf); if(src_offset) - free(src_offset); + HDfree(src_offset); if(src_sizes) - free(src_sizes); + HDfree(src_sizes); H5E_BEGIN_TRY { H5Tclose(mem_type_id); @@ -1509,7 +1509,7 @@ herr_t H5TBinsert_record( hid_t loc_id, goto out; read_nrecords = ntotal_records - start; - tmp_buf = (unsigned char *)calloc((size_t) read_nrecords, type_size); + tmp_buf = (unsigned char *)HDcalloc((size_t) read_nrecords, type_size); /* read the records after the inserted one(s) */ if (H5TBread_records( loc_id, dset_name, start, read_nrecords, type_size, field_offset, field_sizes, tmp_buf ) < 0) @@ -1585,7 +1585,7 @@ herr_t H5TBinsert_record( hid_t loc_id, if (H5Dclose( did ) < 0) return -1; - free( tmp_buf ); + HDfree( tmp_buf ); return 0; @@ -1652,9 +1652,9 @@ herr_t H5TBadd_records_from( hid_t loc_id, if (H5TBget_table_info ( loc_id, dset_name1, &nfields, &ntotal_records ) < 0) goto out; - if(NULL == (src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t)))) + if(NULL == (src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; - if(NULL == (src_sizes = (size_t *)malloc((size_t)nfields * sizeof(size_t)))) + if(NULL == (src_sizes = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)))) goto out; /* get field info */ @@ -1682,7 +1682,7 @@ herr_t H5TBadd_records_from( hid_t loc_id, if (( type_size1 = H5Tget_size( tid_1 )) == 0 ) goto out; - if(NULL == (tmp_buf = (unsigned char *)calloc((size_t)nrecords, type_size1 ))) + if(NULL == (tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, type_size1 ))) goto out; /* define a hyperslab in the dataset of the size of the records */ @@ -1721,22 +1721,22 @@ herr_t H5TBadd_records_from( hid_t loc_id, goto out; if(tmp_buf) - free(tmp_buf); + HDfree(tmp_buf); if(src_offset) - free(src_offset); + HDfree(src_offset); if(src_sizes) - free(src_sizes); + HDfree(src_sizes); return 0; /* error zone */ out: if(tmp_buf) - free(tmp_buf); + HDfree(tmp_buf); if(src_offset) - free(src_offset); + HDfree(src_offset); if(src_sizes) - free(src_sizes); + HDfree(src_sizes); H5E_BEGIN_TRY { H5Dclose(did_1); @@ -1998,7 +1998,7 @@ herr_t H5TBcombine_tables(hid_t loc_id1, did_1 = H5I_BADID; /* Release resources. */ - free(tmp_buf); + HDfree(tmp_buf); tmp_buf = NULL; /*------------------------------------------------------------------------- @@ -2100,13 +2100,13 @@ herr_t H5TBcombine_tables(hid_t loc_id1, out: if(tmp_buf) - free(tmp_buf); + HDfree(tmp_buf); if(tmp_fill_buf) - free(tmp_fill_buf); + HDfree(tmp_fill_buf); if(src_offset) - free(src_offset); + HDfree(src_offset); if(src_sizes) - free(src_sizes); + HDfree(src_sizes); H5E_BEGIN_TRY { if(member_type_id > 0) @@ -2254,7 +2254,7 @@ herr_t H5TBinsert_field( hid_t loc_id, goto out; /* alloc fill value attribute buffer */ - tmp_fill_buf = (unsigned char *)malloc(total_size ); + tmp_fill_buf = (unsigned char *)HDmalloc(total_size ); /* get the fill value attributes */ if ((H5TBAget_fill( loc_id, dset_name, did_1, tmp_fill_buf )) < 0) @@ -2314,7 +2314,7 @@ herr_t H5TBinsert_field( hid_t loc_id, curr_offset += member_size; - free( member_name ); + HDfree( member_name ); /* close the member type */ if(H5Tclose( member_type_id ) < 0) @@ -2349,7 +2349,7 @@ herr_t H5TBinsert_field( hid_t loc_id, *------------------------------------------------------------------------- */ - tmp_buf = (unsigned char *)calloc((size_t)nrecords, (size_t)total_size); + tmp_buf = (unsigned char *)HDcalloc((size_t)nrecords, (size_t)total_size); /* define a hyperslab in the dataset of the size of the records */ offset[0] = 0; @@ -2557,8 +2557,8 @@ herr_t H5TBinsert_field( hid_t loc_id, goto out; /* release resources. */ - free ( tmp_buf ); - free ( tmp_fill_buf ); + HDfree ( tmp_buf ); + HDfree ( tmp_fill_buf ); return 0; @@ -2694,13 +2694,13 @@ herr_t H5TBdelete_field( hid_t loc_id, if (H5Tclose( member_type_id ) < 0) goto out; - free( member_name ); + HDfree( member_name ); break; } - free( member_name ); + HDfree( member_name ); } /* i */ @@ -2722,7 +2722,7 @@ herr_t H5TBdelete_field( hid_t loc_id, curr_offset = 0; /* alloc fill value attribute buffer */ - tmp_fill_buf = (unsigned char *)malloc((size_t) type_size2 ); + tmp_fill_buf = (unsigned char *)HDmalloc((size_t) type_size2 ); /*------------------------------------------------------------------------- * get attributes from previous table in the process @@ -2742,7 +2742,7 @@ herr_t H5TBdelete_field( hid_t loc_id, /* we want to skip the field to delete */ if (H5TB_find_field( member_name, field_name ) > 0 ) { - free( member_name ); + HDfree( member_name ); continue; } @@ -2780,7 +2780,7 @@ herr_t H5TBdelete_field( hid_t loc_id, curr_offset += member_size; - free(member_name); + HDfree(member_name); /* close the member type */ if (H5Tclose(member_type_id) < 0) @@ -2821,7 +2821,7 @@ herr_t H5TBdelete_field( hid_t loc_id, /* skip the field to delete */ if (H5TB_find_field(member_name, field_name) > 0) { - free(member_name); + HDfree(member_name); continue; } @@ -2840,7 +2840,7 @@ herr_t H5TBdelete_field( hid_t loc_id, if (H5Tinsert( read_type_id, member_name, (size_t)0, member_type_id ) < 0) goto out; - tmp_buf = (unsigned char *)calloc((size_t) nrecords, member_size ); + tmp_buf = (unsigned char *)HDcalloc((size_t) nrecords, member_size ); /* read */ if (H5Dread( did_1, read_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp_buf ) < 0) @@ -2881,8 +2881,8 @@ herr_t H5TBdelete_field( hid_t loc_id, goto out; /* release resources. */ - free( member_name ); - free ( tmp_buf ); + HDfree( member_name ); + HDfree ( tmp_buf ); } /* i */ @@ -3007,7 +3007,7 @@ herr_t H5TBdelete_field( hid_t loc_id, goto out; /* Release resources. */ - free ( tmp_fill_buf ); + HDfree ( tmp_fill_buf ); return 0; @@ -3101,7 +3101,7 @@ htri_t H5TBAget_fill(hid_t loc_id, if (H5TBget_table_info ( loc_id, dset_name, &nfields, &nrecords ) < 0) return -1; - src_offset = (size_t *)malloc((size_t)nfields * sizeof(size_t)); + src_offset = (size_t *)HDmalloc((size_t)nfields * sizeof(size_t)); if (src_offset == NULL ) return -1; @@ -3130,12 +3130,12 @@ htri_t H5TBAget_fill(hid_t loc_id, } - free( src_offset ); + HDfree( src_offset ); return has_fill; out: - free( src_offset ); + HDfree( src_offset ); return -1; } @@ -3306,7 +3306,7 @@ herr_t H5TBget_field_info( hid_t loc_id, member_name = H5Tget_member_name(tid, (unsigned)i); strcpy(field_names[i], member_name); - free(member_name); + HDfree(member_name); } /* end if */ /* get the member type */ @@ -3459,7 +3459,7 @@ herr_t H5TB_attach_attributes( const char *table_title, if (H5LTset_attribute_string( loc_id, dset_name, attr_name, member_name ) < 0) goto out; - free( member_name ); + HDfree( member_name ); } @@ -3508,14 +3508,14 @@ hid_t H5TB_create_type(hid_t loc_id, if (H5TBget_table_info(loc_id,dset_name,&nfields,NULL) < 0) return -1; - if ((fnames = (char**) malloc(sizeof(char*)*(size_t)nfields))==NULL) + if ((fnames = (char**) HDmalloc(sizeof(char*)*(size_t)nfields))==NULL) return -1; for ( i = 0; i < nfields; i++) { - if ((fnames[i] = (char*) malloc(sizeof(char)*HLTB_MAX_FIELD_LEN))==NULL) + if ((fnames[i] = (char*) HDmalloc(sizeof(char)*HLTB_MAX_FIELD_LEN))==NULL) { - free(fnames); + HDfree(fnames); return -1; } } @@ -3551,9 +3551,9 @@ hid_t H5TB_create_type(hid_t loc_id, for ( i=0; i<nfields; i++) { - free (fnames[i]); + HDfree (fnames[i]); } - free (fnames); + HDfree (fnames); return mem_type_id; @@ -3567,10 +3567,10 @@ out: for ( i=0; i<nfields; i++) { if (fnames[i]) - free (fnames[i]); + HDfree (fnames[i]); } if (fnames) - free (fnames); + HDfree (fnames); return -1; } diff --git a/hl/src/hdf5_hl.h b/hl/src/hdf5_hl.h index 4643932..e9e3bf1 100644 --- a/hl/src/hdf5_hl.h +++ b/hl/src/hdf5_hl.h @@ -27,7 +27,7 @@ #include "H5LTpublic.h" /* lite */ #include "H5IMpublic.h" /* image */ #include "H5TBpublic.h" /* table */ -#include "H5PTpublic.h" /* table */ +#include "H5PTpublic.h" /* packet table */ #endif /*H5_INCLUDE_HL*/ |