diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2002-06-10 15:31:06 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2002-06-10 15:31:06 (GMT) |
commit | 41aa2ec07316bafd2652d61f0fe2738610537f8f (patch) | |
tree | 5fece94bf985c7b0d0fb9bb7ee66bf633e548211 /src/H5FD.c | |
parent | 5f2b8eee135acaa09d5b6686e1abf472eb97ecc1 (diff) | |
download | hdf5-41aa2ec07316bafd2652d61f0fe2738610537f8f.zip hdf5-41aa2ec07316bafd2652d61f0fe2738610537f8f.tar.gz hdf5-41aa2ec07316bafd2652d61f0fe2738610537f8f.tar.bz2 |
[svn-r5562] Purpose:
Code cleanup
Description:
Allow H5FD_free to return successfully (but ignore) freeing objects with
size 0.
Platforms tested:
FreeBSD 4.5 (sleipnir)
Diffstat (limited to 'src/H5FD.c')
-rw-r--r-- | src/H5FD.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1467,7 +1467,7 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size) } /* end if */ else { /* Return the unused portion of the metadata block to a free list */ - if(file->eoma!=0 && file->cur_meta_block_size!=0) + if(file->eoma!=0) if(H5FD_free(file,H5FD_MEM_DEFAULT,file->eoma,file->cur_meta_block_size)<0) HRETURN_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free metadata block"); @@ -1536,7 +1536,7 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size) } /* end if */ else { /* Return the unused portion of the "small data" block to a free list */ - if(file->eosda!=0 && file->cur_sdata_block_size!=0) + if(file->eosda!=0) if(H5FD_free(file,H5FD_MEM_DRAW,file->eosda,file->cur_sdata_block_size)<0) HRETURN_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free 'small data' block"); @@ -1739,11 +1739,15 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size) /* Check args */ assert(file && file->cls); assert(type>=0 && type<H5FD_MEM_NTYPES); - if (!H5F_addr_defined(addr) || addr>file->maxaddr || 0==size || + if (!H5F_addr_defined(addr) || addr>file->maxaddr || H5F_addr_overflow(addr, size) || addr+size>file->maxaddr) { HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid region"); } + /* Allow 0-sized free's to occur without penalty */ + if(0==size) + HRETURN(SUCCEED); + /* Map request type to free list */ if (H5FD_MEM_DEFAULT==file->cls->fl_map[type]) { mapped_type = type; |