diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Dchunk.c | 13 | ||||
-rw-r--r-- | src/H5Dearray.c | 12 | ||||
-rw-r--r-- | src/H5Dfarray.c | 12 | ||||
-rw-r--r-- | src/H5Dint.c | 37 | ||||
-rw-r--r-- | src/H5Doh.c | 44 | ||||
-rw-r--r-- | src/H5Z.c | 21 |
6 files changed, 86 insertions, 53 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 33fc036..59227de 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -5443,7 +5443,7 @@ herr_t H5D__chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) { H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5O_layout_t layout; /* Dataset layout message */ + H5O_layout_t *layout = NULL; /* Dataset layout message */ hbool_t layout_read = FALSE; /* Whether the layout message was read from the file */ H5O_pline_t pline; /* I/O pipeline message */ hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read from the file */ @@ -5474,7 +5474,9 @@ 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 == H5O_msg_read_oh(f, dxpl_id, oh, H5O_LAYOUT_ID, &layout)) + if(NULL == (layout = (H5O_layout_t *)H5MM_calloc(sizeof(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") layout_read = TRUE; } /* end else if */ @@ -5485,7 +5487,7 @@ H5D__chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) idx_info.f = f; idx_info.dxpl_id = dxpl_id; idx_info.pline = &pline; - idx_info.layout = &layout.u.chunk; + idx_info.layout = &layout->u.chunk; idx_info.storage = &storage->u.chunk; /* Delete the chunked storage information in the file */ @@ -5498,9 +5500,12 @@ done: if(H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset I/O pipeline message") if(layout_read) - if(H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) + if(H5O_msg_reset(H5O_LAYOUT_ID, layout) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout message") + if(layout) + layout = (H5O_layout_t *)H5MM_xfree(layout); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_delete() */ diff --git a/src/H5Dearray.c b/src/H5Dearray.c index 1df0a58..8fea75f 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -37,6 +37,7 @@ #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 */ @@ -629,7 +630,7 @@ H5D__earray_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr) H5D_earray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */ H5O_loc_t obj_loc; /* Pointer to an object's location */ hbool_t obj_opened = FALSE; /* Flag to indicate that the object header was opened */ - H5O_layout_t layout; /* Layout message */ + H5O_layout_t *layout = NULL; /* Layout message */ void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -653,7 +654,9 @@ 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 == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout, dxpl_id)) + if(NULL == (layout = (H5O_layout_t *)H5MM_calloc(sizeof(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") /* close the object header */ @@ -662,7 +665,7 @@ H5D__earray_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr) /* Create user data */ dbg_ctx->f = f; - dbg_ctx->chunk_size = layout.u.chunk.size; + dbg_ctx->chunk_size = layout->u.chunk.size; /* Set return value */ ret_value = dbg_ctx; @@ -681,6 +684,9 @@ done: } /* end if */ } /* end if */ + if(layout) + layout = (H5O_layout_t *)H5MM_xfree(layout); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__earray_crt_dbg_context() */ diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c index d183a8c..b4bd6d6 100644 --- a/src/H5Dfarray.c +++ b/src/H5Dfarray.c @@ -36,6 +36,7 @@ #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 */ @@ -469,7 +470,7 @@ H5D__farray_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr) H5D_farray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */ H5O_loc_t obj_loc; /* Pointer to an object's location */ hbool_t obj_opened = FALSE; /* Flag to indicate that the object header was opened */ - H5O_layout_t layout; /* Layout message */ + H5O_layout_t *layout = NULL; /* Layout message */ void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -493,7 +494,9 @@ 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 == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout, dxpl_id)) + if(NULL == (layout = (H5O_layout_t *)H5MM_calloc(sizeof(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") /* close the object header */ @@ -502,7 +505,7 @@ H5D__farray_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr) /* Create user data */ dbg_ctx->f = f; - dbg_ctx->chunk_size = layout.u.chunk.size; + dbg_ctx->chunk_size = layout->u.chunk.size; /* Set return value */ ret_value = dbg_ctx; @@ -521,6 +524,9 @@ done: } /* end if */ } /* end if */ + if(layout) + layout = (H5O_layout_t *)H5MM_xfree(layout); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__farray_crt_dbg_context() */ diff --git a/src/H5Dint.c b/src/H5Dint.c index 08b3eb8..1da9d12 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -3302,7 +3302,7 @@ H5D_get_create_plist(H5D_t *dset) { H5P_genplist_t *dcpl_plist; /* Dataset's DCPL */ H5P_genplist_t *new_plist; /* Copy of dataset's DCPL */ - H5O_layout_t copied_layout; /* Layout to tweak */ + H5O_layout_t *copied_layout = NULL; /* Layout to tweak */ H5O_fill_t copied_fill; /* Fill value to tweak */ H5O_efl_t copied_efl; /* External file list to tweak */ hid_t new_dcpl_id = FAIL; @@ -3325,39 +3325,41 @@ 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(H5P_peek(new_plist, H5D_CRT_LAYOUT_NAME, &copied_layout) < 0) + if(NULL == (copied_layout = (H5O_layout_t *)H5MM_calloc(sizeof(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") /* Reset layout values set when dataset is created */ - copied_layout.ops = NULL; - switch(copied_layout.type) { + copied_layout->ops = NULL; + switch(copied_layout->type) { case H5D_COMPACT: - copied_layout.storage.u.compact.buf = H5MM_xfree(copied_layout.storage.u.compact.buf); - HDmemset(&copied_layout.storage.u.compact, 0, sizeof(copied_layout.storage.u.compact)); + copied_layout->storage.u.compact.buf = H5MM_xfree(copied_layout->storage.u.compact.buf); + HDmemset(&copied_layout->storage.u.compact, 0, sizeof(copied_layout->storage.u.compact)); break; case H5D_CONTIGUOUS: - copied_layout.storage.u.contig.addr = HADDR_UNDEF; - copied_layout.storage.u.contig.size = 0; + copied_layout->storage.u.contig.addr = HADDR_UNDEF; + copied_layout->storage.u.contig.size = 0; break; case H5D_CHUNKED: /* Reset chunk size */ - copied_layout.u.chunk.size = 0; + copied_layout->u.chunk.size = 0; /* Reset index info, if the chunk ops are set */ - if(copied_layout.storage.u.chunk.ops) - /* Reset address and pointer of the array struct for the chunked storage index */ - if(H5D_chunk_idx_reset(&copied_layout.storage.u.chunk, TRUE) < 0) + if(copied_layout->storage.u.chunk.ops) + /* Reset address and pointer of the array struct for the chunked storage index */ + if(H5D_chunk_idx_reset(&copied_layout->storage.u.chunk, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to reset chunked storage index in dest") /* Reset chunk index ops */ - copied_layout.storage.u.chunk.ops = NULL; + copied_layout->storage.u.chunk.ops = NULL; break; case H5D_VIRTUAL: - copied_layout.storage.u.virt.serial_list_hobjid.addr = HADDR_UNDEF; - copied_layout.storage.u.virt.serial_list_hobjid.idx = 0; + copied_layout->storage.u.virt.serial_list_hobjid.addr = HADDR_UNDEF; + copied_layout->storage.u.virt.serial_list_hobjid.idx = 0; break; case H5D_LAYOUT_ERROR: @@ -3367,7 +3369,7 @@ H5D_get_create_plist(H5D_t *dset) } /* end switch */ /* Set back the (possibly modified) layout property to property list */ - if(H5P_poke(new_plist, H5D_CRT_LAYOUT_NAME, &copied_layout) < 0) + if(H5P_poke(new_plist, H5D_CRT_LAYOUT_NAME, copied_layout) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set layout") /* Get the fill value property */ @@ -3459,6 +3461,9 @@ done: if(H5I_dec_app_ref(new_dcpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") + if(copied_layout) + copied_layout = (H5O_layout_t *)H5MM_xfree(copied_layout); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_get_create_plist() */ diff --git a/src/H5Doh.c b/src/H5Doh.c index 9abbdff..cd70c56 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -27,6 +27,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ @@ -359,12 +360,12 @@ done: static herr_t H5O__dset_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) { - H5O_layout_t layout; /* Data storage layout message */ - H5O_efl_t efl; /* External File List message */ + H5O_layout_t *layout = NULL; /* Data storage layout message */ + H5O_efl_t efl; /* External File List message */ hbool_t layout_read = FALSE; /* Whether the layout message was read */ hbool_t efl_read = FALSE; /* Whether the external file list message was read */ - htri_t exists; /* Flag if header message of interest exists */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t exists; /* Flag if header message of interest exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -376,22 +377,24 @@ 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 == 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") + if(NULL == (layout = (H5O_layout_t *)H5MM_calloc(sizeof(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") layout_read = TRUE; /* Check for chunked dataset storage */ - if(layout.type == H5D_CHUNKED && H5D__chunk_is_space_alloc(&layout.storage)) { + if(layout->type == H5D_CHUNKED && H5D__chunk_is_space_alloc(&(layout->storage))) { /* Get size of chunk index */ - if(H5D__chunk_bh_info(loc, dxpl_id, oh, &layout, &(bh_info->index_size)) < 0) + if(H5D__chunk_bh_info(loc, dxpl_id, oh, layout, &(bh_info->index_size)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't determine chunked dataset btree info") } /* end if */ - else if(layout.type == H5D_VIRTUAL - && (layout.storage.u.virt.serial_list_hobjid.addr != HADDR_UNDEF)) { + else if(layout->type == H5D_VIRTUAL + && (layout->storage.u.virt.serial_list_hobjid.addr != HADDR_UNDEF)) { size_t virtual_heap_size; /* Get size of global heap object for virtual dataset */ - if(H5HG_get_obj_size(loc->file, dxpl_id, &(layout.storage.u.virt.serial_list_hobjid), &virtual_heap_size) < 0) + if(H5HG_get_obj_size(loc->file, dxpl_id, &(layout->storage.u.virt.serial_list_hobjid), &virtual_heap_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get global heap size for virtual dataset mapping") /* Return heap size */ @@ -400,29 +403,32 @@ H5O__dset_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t * /* Check for External File List message in the object header */ if((exists = H5O_msg_exists_oh(oh, H5O_EFL_ID)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for EFL message") + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for EFL message") - if(exists && H5D__efl_is_space_alloc(&layout.storage)) { + if(exists && H5D__efl_is_space_alloc(&(layout->storage))) { /* Start with clean EFL info */ HDmemset(&efl, 0, sizeof(efl)); - /* Get External File List message from the object header */ - if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_EFL_ID, &efl)) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find EFL message") + /* Get External File List message from the object header */ + if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_EFL_ID, &efl)) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find EFL message") efl_read = TRUE; - /* Get size of local heap for EFL message's file list */ - if(H5D__efl_bh_info(loc->file, dxpl_id, &efl, &(bh_info->heap_size)) < 0) + /* Get size of local heap for EFL message's file list */ + if(H5D__efl_bh_info(loc->file, dxpl_id, &efl, &(bh_info->heap_size)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't determine EFL heap info") } /* end if */ done: /* Free messages, if they've been read in */ - if(layout_read && H5O_msg_reset(H5O_LAYOUT_ID, &layout) < 0) + if(layout_read && H5O_msg_reset(H5O_LAYOUT_ID, layout) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset data storage layout message") if(efl_read && H5O_msg_reset(H5O_EFL_ID, &efl) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset external file list message") + if(layout) + layout = (H5O_layout_t *)H5MM_xfree(layout); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_bh_info() */ @@ -811,8 +811,9 @@ done: static herr_t H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_type) { - hid_t space_id = -1; /* ID for dataspace describing chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t space_id = -1; /* ID for dataspace describing chunk */ + H5O_layout_t *dcpl_layout = NULL; /* Dataset's layout information */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -822,18 +823,20 @@ H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type /* Check if the property list is non-default */ if(dcpl_id != H5P_DATASET_CREATE_DEFAULT) { H5P_genplist_t *dc_plist; /* Dataset creation property list object */ - H5O_layout_t dcpl_layout; /* Dataset's layout information */ + + if(NULL == (dcpl_layout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't get memory for layout") /* Get dataset creation property list object */ if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") /* Peek at the layout information */ - if(H5P_peek(dc_plist, H5D_CRT_LAYOUT_NAME, &dcpl_layout) < 0) + if(H5P_peek(dc_plist, H5D_CRT_LAYOUT_NAME, dcpl_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") /* Check if the dataset is chunked */ - if(H5D_CHUNKED == dcpl_layout.type) { + if(H5D_CHUNKED == dcpl_layout->type) { H5O_pline_t dcpl_pline; /* Object's I/O pipeline information */ /* Get I/O pipeline information */ @@ -847,9 +850,9 @@ H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type size_t u; /* Local index variable */ /* Create a data space for a chunk & set the extent */ - for(u = 0; u < dcpl_layout.u.chunk.ndims; u++) - chunk_dims[u] = dcpl_layout.u.chunk.dim[u]; - if(NULL == (space = H5S_create_simple(dcpl_layout.u.chunk.ndims, chunk_dims, NULL))) + for(u = 0; u < dcpl_layout->u.chunk.ndims; u++) + chunk_dims[u] = dcpl_layout->u.chunk.dim[u]; + if(NULL == (space = H5S_create_simple(dcpl_layout->u.chunk.ndims, chunk_dims, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Get ID for dataspace to pass to filter routines */ @@ -868,6 +871,8 @@ H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type 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); FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_prepare_prelude_callback_dcpl() */ |