From 390b5a9febece77f236f4361983c4ef9dbeb394d Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 7 Jun 2017 13:38:27 -0400 Subject: Updated H5O_layout_t dynamic work to use the H5FL interface. --- src/H5Dchunk.c | 7 +++++-- src/H5Dearray.c | 10 ++++++---- src/H5Dfarray.c | 8 +++++--- src/H5Dint.c | 7 +++++-- src/H5Doh.c | 8 +++++--- src/H5Omessage.c | 10 +++++----- src/H5Z.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++--------- 7 files changed, 79 insertions(+), 28 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 59227de..a927736 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -368,6 +368,9 @@ H5FL_BLK_DEFINE_STATIC(chunk); /* Declare extern free list to manage the H5S_sel_iter_t struct */ H5FL_EXTERN(H5S_sel_iter_t); +/* Declare a free list to manage the H5O_layout_t struct */ +H5FL_DEFINE_STATIC(H5O_layout_t); + /*------------------------------------------------------------------------- * Function: H5D__chunk_direct_write @@ -5474,7 +5477,7 @@ H5D__chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) if((exists = H5O_msg_exists_oh(oh, H5O_LAYOUT_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to check for object header message") else if(exists) { - if(NULL == (layout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) + if(NULL == (layout = H5FL_CALLOC(H5O_layout_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't get memory for layout") if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_LAYOUT_ID, layout)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout message") @@ -5504,7 +5507,7 @@ done: HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout message") if(layout) - layout = (H5O_layout_t *)H5MM_xfree(layout); + layout = H5FL_FREE(H5O_layout_t, layout); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_delete() */ diff --git a/src/H5Dearray.c b/src/H5Dearray.c index 8fea75f..bbff8b8 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -37,7 +37,6 @@ #include "H5EAprivate.h" /* Extensible arrays */ #include "H5FLprivate.h" /* Free Lists */ #include "H5MFprivate.h" /* File space management */ -#include "H5MMprivate.h" /* Memory management */ #include "H5VMprivate.h" /* Vector functions */ @@ -215,10 +214,13 @@ const H5EA_class_t H5EA_CLS_FILT_CHUNK[1]={{ /*******************/ /* Declare a free list to manage the H5D_earray_ctx_t struct */ -/* Declare a free list to manage the H5D_earray_ctx_ud_t struct */ H5FL_DEFINE_STATIC(H5D_earray_ctx_t); + +/* Declare a free list to manage the H5D_earray_ctx_ud_t struct */ H5FL_DEFINE_STATIC(H5D_earray_ctx_ud_t); +/* Declare a free list to manage the H5O_layout_t struct */ +H5FL_DEFINE_STATIC(H5O_layout_t); /*------------------------------------------------------------------------- @@ -654,7 +656,7 @@ H5D__earray_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr) obj_opened = TRUE; /* Read the layout message */ - if(NULL == (layout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) + if(NULL == (layout = H5FL_CALLOC(H5O_layout_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't get memory for layout") if(NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, layout, dxpl_id)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get layout info") @@ -685,7 +687,7 @@ done: } /* end if */ if(layout) - layout = (H5O_layout_t *)H5MM_xfree(layout); + layout = H5FL_FREE(H5O_layout_t, layout); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_crt_dbg_context() */ diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c index b4bd6d6..62c4150 100644 --- a/src/H5Dfarray.c +++ b/src/H5Dfarray.c @@ -36,7 +36,6 @@ #include "H5FAprivate.h" /* Fixed arrays */ #include "H5FLprivate.h" /* Free Lists */ #include "H5MFprivate.h" /* File space management */ -#include "H5MMprivate.h" /* Memory management */ #include "H5VMprivate.h" /* Vector functions */ @@ -218,6 +217,9 @@ H5FL_DEFINE_STATIC(H5D_farray_ctx_t); /* Declare a free list to manage the H5D_farray_ctx_ud_t struct */ H5FL_DEFINE_STATIC(H5D_farray_ctx_ud_t); +/* Declare a free list to manage the H5O_layout_t struct */ +H5FL_DEFINE_STATIC(H5O_layout_t); + /*------------------------------------------------------------------------- * Function: H5D__farray_crt_context @@ -494,7 +496,7 @@ H5D__farray_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr) obj_opened = TRUE; /* Read the layout message */ - if(NULL == (layout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) + if(NULL == (layout = H5FL_CALLOC(H5O_layout_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't get memory for layout") if(NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, layout, dxpl_id)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get layout info") @@ -525,7 +527,7 @@ done: } /* end if */ if(layout) - layout = (H5O_layout_t *)H5MM_xfree(layout); + layout = H5FL_FREE(H5O_layout_t, layout); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_crt_dbg_context() */ diff --git a/src/H5Dint.c b/src/H5Dint.c index 1da9d12..f1ba594 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -104,6 +104,9 @@ H5FL_EXTERN(H5D_chunk_info_t); /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); +/* Declare a free list to manage the H5O_layout_t struct */ +H5FL_DEFINE_STATIC(H5O_layout_t); + /* Define a static "default" dataset structure to use to initialize new datasets */ static H5D_shared_t H5D_def_dset; @@ -3325,7 +3328,7 @@ H5D_get_create_plist(H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object creation info") /* Get the layout property */ - if(NULL == (copied_layout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) + if(NULL == (copied_layout = H5FL_CALLOC(H5O_layout_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't get memory for layout") if(H5P_peek(new_plist, H5D_CRT_LAYOUT_NAME, copied_layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout") @@ -3462,7 +3465,7 @@ done: HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") if(copied_layout) - copied_layout = (H5O_layout_t *)H5MM_xfree(copied_layout); + copied_layout = H5FL_FREE(H5O_layout_t, copied_layout); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_get_create_plist() */ diff --git a/src/H5Doh.c b/src/H5Doh.c index cd70c56..bd83780 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -27,7 +27,6 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ @@ -88,6 +87,9 @@ const H5O_obj_class_t H5O_OBJ_DATASET[1] = {{ /* Declare a free list to manage the H5D_copy_file_ud_t struct */ H5FL_DEFINE(H5D_copy_file_ud_t); +/* Declare a free list to manage the H5O_layout_t struct */ +H5FL_DEFINE_STATIC(H5O_layout_t); + /*------------------------------------------------------------------------- * Function: H5O__dset_get_copy_file_udata @@ -377,7 +379,7 @@ H5O__dset_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t * HDassert(bh_info); /* Get the layout message from the object header */ - if(NULL == (layout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) + if(NULL == (layout = H5FL_CALLOC(H5O_layout_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't get memory for layout") if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_LAYOUT_ID, layout)) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find layout message") @@ -427,7 +429,7 @@ done: HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset external file list message") if(layout) - layout = (H5O_layout_t *)H5MM_xfree(layout); + layout = H5FL_FREE(H5O_layout_t, layout); FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_bh_info() */ diff --git a/src/H5Omessage.c b/src/H5Omessage.c index 158701b..90c2b23 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -732,12 +732,12 @@ H5O_msg_free_real(const H5O_msg_class_t *type, void *msg_native) /*------------------------------------------------------------------------- * Function: H5O_msg_copy * - * Purpose: Copies a message. If MESG is is the null pointer then a null - * pointer is returned with no error. + * Purpose: Copies a message. If MESG is is the null pointer then a null + * pointer is returned with no error. * - * Return: Success: Ptr to the new message + * Return: Success: Ptr to the new message * - * Failure: NULL + * Failure: NULL * * Programmer: Robb Matzke * Thursday, May 21, 1998 @@ -748,7 +748,7 @@ void * H5O_msg_copy(unsigned type_id, const void *mesg, void *dst) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5Z.c b/src/H5Z.c index de84a9e..be8c0ed 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -11,13 +11,21 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/****************/ +/* Module Setup */ +/****************/ + #include "H5Zmodule.h" /* This source code file is part of the H5Z module */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Dataset functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File */ +#include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ @@ -30,7 +38,16 @@ # include "szlib.h" #endif -/* Local typedefs */ + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + #ifdef H5Z_DEBUG typedef struct H5Z_stats_t { struct { @@ -55,19 +72,41 @@ typedef enum { /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; -/* Local variables */ + +/********************/ +/* Local Prototypes */ +/********************/ +static int H5Z_find_idx(H5Z_filter_t id); +static int H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t obj_id, void *key); +static int H5Z__check_unregister_group_cb(void *obj_ptr, hid_t obj_id, void *key); +static int H5Z__flush_file_cb(void *obj_ptr, hid_t obj_id, void *key); + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + static size_t H5Z_table_alloc_g = 0; static size_t H5Z_table_used_g = 0; static H5Z_class2_t *H5Z_table_g = NULL; + #ifdef H5Z_DEBUG static H5Z_stats_t *H5Z_stat_table_g = NULL; #endif /* H5Z_DEBUG */ -/* Local functions */ -static int H5Z_find_idx(H5Z_filter_t id); -static int H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t obj_id, void *key); -static int H5Z__check_unregister_group_cb(void *obj_ptr, hid_t obj_id, void *key); -static int H5Z__flush_file_cb(void *obj_ptr, hid_t obj_id, void *key); +/* Declare a free list to manage the H5O_layout_t struct */ +H5FL_DEFINE_STATIC(H5O_layout_t); + /*------------------------------------------------------------------------- @@ -824,7 +863,7 @@ H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type if(dcpl_id != H5P_DATASET_CREATE_DEFAULT) { H5P_genplist_t *dc_plist; /* Dataset creation property list object */ - if(NULL == (dcpl_layout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) + if(NULL == (dcpl_layout = H5FL_CALLOC(H5O_layout_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't get memory for layout") /* Get dataset creation property list object */ @@ -872,7 +911,7 @@ done: if(space_id > 0 && H5I_dec_ref(space_id) < 0) HDONE_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") if(dcpl_layout) - dcpl_layout = (H5O_layout_t *)H5MM_xfree(dcpl_layout); + dcpl_layout = H5FL_FREE(H5O_layout_t, dcpl_layout); FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_prepare_prelude_callback_dcpl() */ -- cgit v0.12