[svn-r17351] Description:

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
        FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
        Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
                                in debug mode
        Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
                                w/C++ & FORTRAN, in production mode
        Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
                                w/szip filter, in production mode
        Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
                                in production mode
        Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
        Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
This commit is contained in:
Quincey Koziol 2009-08-13 12:09:55 -05:00
parent aa13114bb8
commit 7bcb57d578
11 changed files with 54 additions and 26 deletions

View File

@ -355,7 +355,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);

View File

@ -6274,6 +6274,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;

View File

@ -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() */

View File

@ -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;

View File

@ -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:

View File

@ -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 */

View File

@ -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() */

View File

@ -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)

View File

@ -5293,13 +5293,13 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
ret = H5Dclose(dset3);
CHECK(ret, FAIL, "H5Dclose");
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
} /* test_attr_corder_transition() */

View File

@ -88,3 +88,4 @@ main(int argc, char *argv[])
return (GetTestNumErrs());
} /* end main() */

View File

@ -2831,7 +2831,7 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
ret = H5Dvlen_reclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Dclose(dset_id);
@ -3001,7 +3001,7 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
ret = H5Dvlen_reclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Dclose(dset_id);
@ -3097,7 +3097,7 @@ test_vltypes_fill_value(void)
} /* end for */
/* Release the space */
ret = H5Dvlen_reclaim(dtype1_id, dset_dspace_id, xfer_pid, rbuf);
ret = H5Dvlen_reclaim(dtype1_id, dset_select_dspace_id, xfer_pid, rbuf);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
ret = H5Dclose(dset_id);