summaryrefslogtreecommitdiffstats
path: root/src/H5FD.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-06-06 13:54:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-06-06 13:54:26 (GMT)
commit754f4780f236297a6a905c83cfd051361d654f8f (patch)
tree645a11b9ff5a2d7bdbba02f8ab1440dee567fdec /src/H5FD.c
parent7292287c89df97b6d8bbe062b95b4f469e7fa9ad (diff)
downloadhdf5-754f4780f236297a6a905c83cfd051361d654f8f.zip
hdf5-754f4780f236297a6a905c83cfd051361d654f8f.tar.gz
hdf5-754f4780f236297a6a905c83cfd051361d654f8f.tar.bz2
[svn-r5542] Purpose:
Code cleanup/bug fix Description: Unused space in the file was being "dropped on the floor" when the metadata or "small data" block was moved to a new location in the file and there was unused space in the old block. Solution: Put the space left in the allocation block into the free list of space for the file. This allows it to be [potentially] reused and sometimes allows the file to be smaller. Platforms tested: Solaris 2.7 (arabica) w/FORTRAN and FreeBSD 4.5 (sleipnir) w/C++
Diffstat (limited to 'src/H5FD.c')
-rw-r--r--src/H5FD.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/H5FD.c b/src/H5FD.c
index fe43159..129b133 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -1466,12 +1466,12 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size)
file->cur_meta_block_size+=file->def_meta_block_size;
} /* end if */
else {
- /*
- * Instead of just dropping the remainder of the block on the
- * floor and leaving the space in the file unused, we should
- * return this small piece of unused space to the free list
- * management. - QAK
- */
+ /* Return the unused portion of the metadata block to a free list */
+ 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");
+
+ /* Point the metadata block at the newly allocated block */
file->eoma=new_meta;
file->cur_meta_block_size=file->def_meta_block_size;
} /* end else */
@@ -1535,12 +1535,12 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size)
file->cur_sdata_block_size+=file->def_sdata_block_size;
} /* end if */
else {
- /*
- * Instead of just dropping the remainder of the block on the
- * floor and leaving the space in the file unused, we should
- * return this small piece of unused space to the free list
- * management. - QAK
- */
+ /* Return the unused portion of the "small data" block to a free list */
+ 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");
+
+ /* Point the "small data" block at the newly allocated block */
file->eosda=new_data;
file->cur_sdata_block_size=file->def_sdata_block_size;
} /* end else */
@@ -2591,14 +2591,14 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
/* Check if we should shrink the accumulator buffer */
if(size<(file->accum_buf_size/H5FD_ACCUM_THROTTLE) &&
file->accum_buf_size>H5FD_ACCUM_THRESHOLD) {
- size_t new_size=(file->accum_buf_size/H5FD_ACCUM_THROTTLE); /* New size of accumulator buffer */
+ size_t tmp_size=(file->accum_buf_size/H5FD_ACCUM_THROTTLE); /* New size of accumulator buffer */
/* Shrink the accumulator buffer */
- if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,new_size))==NULL)
+ if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,tmp_size))==NULL)
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
/* Note the new buffer size */
- file->accum_buf_size=new_size;
+ file->accum_buf_size=tmp_size;
} /* end if */
} /* end else */