diff options
-rw-r--r-- | src/H5A.c | 25 | ||||
-rw-r--r-- | src/H5Gnode.c | 14 | ||||
-rw-r--r-- | src/H5Oattr.c | 5 | ||||
-rw-r--r-- | src/H5Ostab.c | 16 |
4 files changed, 34 insertions, 26 deletions
@@ -55,6 +55,9 @@ static herr_t H5A_find_idx_by_name(const void *mesg, unsigned idx, void *op_data /* Declare the free lists for H5A_t's */ H5FL_DEFINE(H5A_t); +/* Declare a free list to manage blocks of type conversion data */ +H5FL_BLK_DEFINE(attr_buf); + /*-------------------------------------------------------------------------- NAME @@ -686,7 +689,7 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) /* Get the maximum buffer size needed and allocate it */ buf_size=nelmts*MAX(src_type_size,dst_type_size); - if (NULL==(tconv_buf = H5MM_malloc (buf_size)) || NULL==(bkg_buf = H5MM_calloc(buf_size))) + if (NULL==(tconv_buf = H5FL_BLK_MALLOC (attr_buf, buf_size)) || NULL==(bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the user's data into the buffer for conversion */ @@ -698,7 +701,7 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) /* Free the previous attribute data buffer, if there is one */ if(attr->data) - H5MM_xfree(attr->data); + H5FL_BLK_FREE(attr_buf, attr->data); /* Set the pointer to the attribute data to the converted information */ attr->data=tconv_buf; @@ -709,7 +712,7 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) /* Allocate the attribute buffer, if there isn't one */ if(attr->data==NULL) - if (NULL==(attr->data = H5MM_malloc (dst_type_size*nelmts))) + if (NULL==(attr->data = H5FL_BLK_MALLOC(attr_buf, dst_type_size*nelmts))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the attribute data into the user's buffer */ @@ -735,7 +738,7 @@ done: if (dst_id >= 0) (void)H5I_dec_ref(dst_id); if (bkg_buf) - H5MM_xfree(bkg_buf); + H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) } /* H5A_write() */ @@ -852,7 +855,7 @@ H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id) /* Get the maximum buffer size needed and allocate it */ buf_size=nelmts*MAX(src_type_size,dst_type_size); - if (NULL==(tconv_buf = H5MM_malloc (buf_size)) || NULL==(bkg_buf = H5MM_calloc(buf_size))) + if (NULL==(tconv_buf = H5FL_BLK_MALLOC(attr_buf, buf_size)) || NULL==(bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the attribute data into the buffer for conversion */ @@ -882,9 +885,9 @@ done: if (dst_id >= 0) (void)H5I_dec_ref(dst_id); if (tconv_buf) - H5MM_xfree(tconv_buf); + H5FL_BLK_FREE(attr_buf, tconv_buf); if (bkg_buf) - H5MM_xfree(bkg_buf); + H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) } /* H5A_read() */ @@ -1556,7 +1559,7 @@ H5A_copy(H5A_t *_new_attr, const H5A_t *old_attr, unsigned update_flags) } /* end if */ if(old_attr->data) { if(!(update_flags&H5O_UPDATE_DATA_ONLY) || new_attr->data==NULL) { - if (NULL==(new_attr->data=H5MM_malloc(old_attr->data_size))) + if (NULL==(new_attr->data=H5FL_BLK_MALLOC(attr_buf,old_attr->data_size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* end if */ HDmemcpy(new_attr->data,old_attr->data,old_attr->data_size); @@ -1609,7 +1612,7 @@ H5A_free(H5A_t *attr) if(H5S_close(attr->ds)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info") if(attr->data) - H5MM_xfree(attr->data); + H5FL_BLK_FREE(attr_buf, attr->data); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1641,7 +1644,7 @@ H5A_close(H5A_t *attr) /* Check if the attribute has any data yet, if not, fill with zeroes */ if(attr->ent_opened && !attr->initialized) { - uint8_t *tmp_buf=H5MM_calloc(attr->data_size); + uint8_t *tmp_buf=H5FL_BLK_CALLOC(attr_buf, attr->data_size); if (NULL == tmp_buf) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "memory allocation failed for attribute fill-value") @@ -1650,7 +1653,7 @@ H5A_close(H5A_t *attr) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") /* Free temporary buffer */ - H5MM_xfree(tmp_buf); + H5FL_BLK_FREE(attr_buf, tmp_buf); } /* end if */ /* Free dynamicly allocated items */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 2f83d28..e690108 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -30,6 +30,10 @@ #define H5G_PACKAGE /*suppress error message about including H5Gpkg.h */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ +/* Pablo information */ +/* (Put before include files to avoid problems with inline functions) */ +#define PABLO_MASK H5G_node_mask + /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ @@ -59,8 +63,6 @@ typedef struct H5G_node_key_t { #define H5G_NODE_VERS 1 /*symbol table node version number */ #define H5G_NODE_SIZEOF_HDR(F) (H5G_NODE_SIZEOF_MAGIC + 4) -#define PABLO_MASK H5G_node_mask - /* PRIVATE PROTOTYPES */ static herr_t H5G_node_serialize(H5F_t *f, H5G_node_t *sym, size_t size, uint8_t *buf); static size_t H5G_node_size(H5F_t *f); @@ -1484,7 +1486,7 @@ H5G_node_iterate (H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr, if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node"); nsyms = sn->nsyms; - if (NULL==(name_off = H5MM_malloc (nsyms*sizeof(name_off[0])))) + if (NULL==(name_off = H5FL_SEQ_MALLOC(size_t, nsyms))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, H5B_ITER_ERROR, "memory allocation failed"); for (i=0; i<nsyms; i++) name_off[i] = sn->entry[i].name_off; @@ -1541,7 +1543,9 @@ done: if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header"); - name_off = H5MM_xfree (name_off); + if(name_off) + H5FL_SEQ_FREE(size_t,name_off); + FUNC_LEAVE_NOAPI(ret_value); } @@ -1789,7 +1793,7 @@ done: herr_t H5G_node_close(const H5F_t *f) { - FUNC_ENTER_NOAPI_NOFUNC(H5G_node_close) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_close) /* Check arguments. */ assert(f); diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 28da005..476589c 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -71,6 +71,9 @@ const H5O_class_t H5O_ATTR[1] = {{ /* Declare extern the free list for H5A_t's */ H5FL_EXTERN(H5A_t); +/* Declare extern the free list for attribute data buffers */ +H5FL_BLK_EXTERN(attr_buf); + /* Declare external the free list for H5S_t's */ H5FL_EXTERN(H5S_t); @@ -203,7 +206,7 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED * /* Go get the data */ if(attr->data_size) { - if (NULL==(attr->data = H5MM_malloc(attr->data_size))) + if (NULL==(attr->data = H5FL_BLK_MALLOC(attr_buf, attr->data_size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); HDmemcpy(attr->data,p,attr->data_size); } diff --git a/src/H5Ostab.c b/src/H5Ostab.c index 4b061df..0fbda05 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -176,8 +176,7 @@ H5O_stab_encode(H5F_t *f, uint8_t *p, const void *_mesg) void * H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg) { - H5O_stab_t *stab = NULL; - void *ret_value; /* Return value */ + H5O_stab_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_stab_fast); @@ -187,16 +186,15 @@ H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg) if (H5O_STAB == type) { if (_mesg) { - stab = (H5O_stab_t *) _mesg; - } else if (NULL==(stab = H5FL_CALLOC(H5O_stab_t))) { + ret_value = (H5O_stab_t *) _mesg; + } else if (NULL==(ret_value = H5FL_MALLOC(H5O_stab_t))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } - stab->btree_addr = cache->stab.btree_addr; - stab->heap_addr = cache->stab.heap_addr; + ret_value->btree_addr = cache->stab.btree_addr; + ret_value->heap_addr = cache->stab.heap_addr; } - - /* Set return value */ - ret_value=stab; + else + ret_value=NULL; done: FUNC_LEAVE_NOAPI(ret_value); |