diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-08-13 19:17:29 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-08-13 19:17:29 (GMT) |
commit | 92b37616d2a1ec34a2d7bd34d05c5f6466f7da53 (patch) | |
tree | 782bdfeee57df4a5fc673c47c1917e92f6262468 /src | |
parent | 5e435bd8ac0b1d59a2c8461b960434b49b50a25f (diff) | |
download | hdf5-92b37616d2a1ec34a2d7bd34d05c5f6466f7da53.zip hdf5-92b37616d2a1ec34a2d7bd34d05c5f6466f7da53.tar.gz hdf5-92b37616d2a1ec34a2d7bd34d05c5f6466f7da53.tar.bz2 |
[svn-r17354] Description:
Bring r17351 from trunk to 1.8 branch:
Clean up code (to align w/future sblock_mdc branch changes), tweak
tests for [slightly] easier debugging, fix memory leak when copying chunked
datasets with I/O filters, fix memory leak of free space section when it was
exactly the right size to use for extending an existing block in the file.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
(h5committest performed on trunk)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Bcache.c | 2 | ||||
-rw-r--r-- | src/H5C.c | 4 | ||||
-rw-r--r-- | src/H5Dchunk.c | 12 | ||||
-rw-r--r-- | src/H5FSsection.c | 19 | ||||
-rw-r--r-- | src/H5Fdbg.c | 2 | ||||
-rw-r--r-- | src/H5Groot.c | 4 | ||||
-rw-r--r-- | src/H5MFaggr.c | 12 | ||||
-rwxr-xr-x | src/H5SM.c | 10 |
8 files changed, 46 insertions, 19 deletions
diff --git a/src/H5Bcache.c b/src/H5Bcache.c index dd5b613..57a012c 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -354,7 +354,7 @@ H5B_dest(H5F_t *f, H5B_t *bt) } /* end if */ /* Release resources for B-tree node */ - H5FL_SEQ_FREE(haddr_t, bt->child); + bt->child = H5FL_SEQ_FREE(haddr_t, bt->child); bt->native = H5FL_BLK_FREE(native_block, bt->native); H5RC_DEC(bt->rc_shared); bt = H5FL_FREE(H5B_t, bt); @@ -6202,6 +6202,10 @@ H5C_protect(H5F_t * f, if ( entry_ptr != NULL ) { + /* Check for trying to load the wrong type of entry from an address */ + if(entry_ptr->type != type) + HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "not a dataset creation property list") + hit = TRUE; thing = (void *)entry_ptr; diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index b22a097..0d0c77a 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -3967,7 +3967,9 @@ 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 */ + 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 */ htri_t exists; /* Flag if header message of interest exists */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3984,6 +3986,7 @@ H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) else if(exists) { if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_PLINE_ID, &pline)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O pipeline message") + pline_read = TRUE; } /* end else if */ else HDmemset(&pline, 0, sizeof(pline)); @@ -3994,6 +3997,7 @@ H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) else if(exists) { 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 */ else HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "can't find layout message") @@ -4010,6 +4014,14 @@ H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk index") done: + /* Clean up any messages read in */ + if(pline_read) + 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) + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout message") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_delete() */ diff --git a/src/H5FSsection.c b/src/H5FSsection.c index 51229cb..26ff7b9 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -1124,7 +1124,6 @@ done: } /* H5FS_sect_link() */ - /*------------------------------------------------------------------------- * Function: H5FS_sect_merge * @@ -1508,10 +1507,15 @@ if(_section_) * (or it would have been eliminated), etc) */ if(sect->size >= extra_requested && (addr + size) == sect->addr) { + H5FS_section_class_t *cls; /* Section's class */ + /* Remove section from data structures */ if(H5FS_sect_remove_real(fspace, sect) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTRELEASE, FAIL, "can't remove section from internal data structures") + /* Get class for section */ + cls = &fspace->sect_cls[sect->type]; + /* Check for the section needing to be adjusted and re-added */ /* (Note: we should probably add a can_adjust/adjust callback * to the section class structure, but we don't need it @@ -1519,11 +1523,6 @@ if(_section_) * it. - QAK - 2008/01/08) */ if(sect->size > extra_requested) { - H5FS_section_class_t *cls; /* Section's class */ - - /* Get class for section */ - cls = &fspace->sect_cls[sect->type]; - /* Sanity check (for now) */ HDassert(cls->flags & H5FS_CLS_ADJUST_OK); @@ -1535,6 +1534,14 @@ if(_section_) if(H5FS_sect_link(fspace, sect, 0) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") } /* end if */ + else { + /* Sanity check */ + HDassert(sect->size == extra_requested); + + /* Exact match, so just free section */ + if((*cls->free)(sect) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't free section") + } /* end else */ /* Note that we modified the section info */ sinfo_modified = TRUE; diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c index a4577c9..b570516 100644 --- a/src/H5Fdbg.c +++ b/src/H5Fdbg.c @@ -142,7 +142,7 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) /* Display root group symbol table entry info */ H5G_ent_debug(f, &root_ent, stream, indent + 3, MAX(0, fwidth - 3), NULL); - } + } /* end else */ } /* end if */ done: diff --git a/src/H5Groot.c b/src/H5Groot.c index b8a1468..9d3fc6f 100644 --- a/src/H5Groot.c +++ b/src/H5Groot.c @@ -13,7 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /*------------------------------------------------------------------------- +/*------------------------------------------------------------------------- * * Created: H5Gobj.c * Apr 8 2009 @@ -107,7 +107,7 @@ H5G_root_ent_decode(H5F_t *f, const uint8_t **pp) /* Allocate space for the root group symbol table entry */ HDassert(!f->shared->root_ent); - if(NULL == (f->shared->root_ent = (H5G_entry_t *) H5MM_calloc(sizeof(H5G_entry_t)))) + if(NULL == (f->shared->root_ent = (H5G_entry_t *)H5MM_calloc(sizeof(H5G_entry_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate space for symbol table entry") /* decode the root group symbol table entry */ diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index 0526ef2..616d705 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -152,13 +152,13 @@ haddr_t H5MF_aggr_alloc(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5FD_mem_t type, hsize_t size) { - haddr_t ret_value; hsize_t alignment = 0, mis_align = 0; haddr_t frag_addr = 0, eoa_frag_addr = 0; hsize_t frag_size = 0, eoa_frag_size = 0; haddr_t eoa = 0, new_space = 0; htri_t extended = 0; H5FD_mem_t alloc_type, other_alloc_type; + haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5MF_aggr_alloc, HADDR_UNDEF) #ifdef H5MF_AGGR_DEBUG @@ -234,6 +234,7 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz other_aggr->size = 0; } /* end if */ + /* Allocate space from the VFD (i.e. at the end of the file) */ if(HADDR_UNDEF == (new_space = H5FD_alloc(f->shared->lf, dxpl_id, type, size, &eoa_frag_addr, &eoa_frag_size))) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate aggregation block") @@ -277,6 +278,7 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); other_aggr->size = 0; } /* end if */ + /* Allocate space from the VFD (i.e. at the end of the file) */ if(HADDR_UNDEF == (new_space = H5FD_alloc(f->shared->lf, dxpl_id, alloc_type, aggr->alloc_size, &eoa_frag_addr, &eoa_frag_size))) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate aggregation block") @@ -297,12 +299,12 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); aggr->addr += size; } /* end else */ - /* freeing any possible fragment due to file allocation */ + /* Freeing any possible fragment due to file allocation */ if(eoa_frag_size) if(H5MF_xfree(f, type, dxpl_id, eoa_frag_addr, eoa_frag_size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") - /* freeing any possible fragment due to alignment in the block after extension */ + /* Freeing any possible fragment due to alignment in the block after extension */ if(extended && frag_size) if(H5MF_xfree(f, type, dxpl_id, frag_addr, frag_size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free aggregation fragment") @@ -327,7 +329,9 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); /* Allocate data from the file */ if(HADDR_UNDEF == (ret_value = H5FD_alloc(f->shared->lf, dxpl_id, type, size, &eoa_frag_addr, &eoa_frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") + /* Check if fragment was generated */ if(eoa_frag_size) + /* Put fragment on the free list */ if(H5MF_xfree(f, type, dxpl_id, eoa_frag_addr, eoa_frag_size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") } /* end else */ @@ -339,7 +343,7 @@ done: #ifdef H5MF_AGGR_DEBUG HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); #endif /* H5MF_AGGR_DEBUG */ - if (alignment) + if(alignment) HDassert(!(ret_value % alignment)); FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF_aggr_alloc() */ @@ -139,10 +139,6 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc, hid_t d /* File should not already have a SOHM table */ HDassert(f->shared->sohm_addr == HADDR_UNDEF); - /* Initialize master table */ - if(NULL == (table = H5FL_MALLOC(H5SM_master_table_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for SOHM table") - /* Get information from fcpl */ if(H5P_get(fc_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &num_indexes)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes") @@ -167,6 +163,10 @@ H5SM_init(H5F_t *f, H5P_genplist_t * fc_plist, const H5O_loc_t *ext_loc, hid_t d type_flags_used |= index_type_flags[x]; } /* end for */ + /* Initialize master table */ + if(NULL == (table = H5FL_MALLOC(H5SM_master_table_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for SOHM table") + /* Set version and number of indexes in table and in superblock. * Right now we just use one byte to hold the number of indexes. */ @@ -235,7 +235,7 @@ done: if(table_addr != HADDR_UNDEF) H5MF_xfree(f, H5FD_MEM_SOHM_TABLE, dxpl_id, table_addr, (hsize_t)H5SM_TABLE_SIZE(f)); if(table != NULL) - (void)H5FL_FREE(H5SM_master_table_t, table); + table = H5FL_FREE(H5SM_master_table_t, table); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) |