diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-11-16 20:45:05 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-11-16 20:45:05 (GMT) |
commit | d2b87ec47ebdb096c331c7b62a195b9cea2f33ae (patch) | |
tree | a066f01361afaf5df457cef612bb0bb9fd80fe18 /src/H5HGcache.c | |
parent | ee5a1e07350f0dcf3ef07d9443aa2f4c073392f4 (diff) | |
download | hdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.zip hdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.tar.gz hdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.tar.bz2 |
[svn-r17896] Description:
Bring r17546:17895 from trunk to revise_chunks branch. Changes to
fixed and extensible array dataset chunk indexing code to accommodate changes
to private APIs in those interfaces. Also, other adjustments to source code
and expected output in response to changes on the trunk.
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 (jam) w/PGI compilers, w/default API=1.8.x,
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 debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Diffstat (limited to 'src/H5HGcache.c')
-rw-r--r-- | src/H5HGcache.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/H5HGcache.c b/src/H5HGcache.c index f3d0f3a..ee318aa 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -171,11 +171,12 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, /* Decode each object */ p = heap->chunk + H5HG_SIZEOF_HDR(f); nalloc = H5HG_NOBJS(f, heap->size); - if(NULL == (heap->obj = H5FL_SEQ_MALLOC(H5HG_obj_t, nalloc))) + + /* Calloc the obj array because the file format spec makes no guarantee + * about the order of the objects, and unused slots must be set to zero. + */ + if(NULL == (heap->obj = H5FL_SEQ_CALLOC(H5HG_obj_t, nalloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - heap->obj[0].nrefs = 0; - heap->obj[0].size = 0; - heap->obj[0].begin = NULL; heap->nalloc = nalloc; while(p < (heap->chunk + heap->size)) { @@ -202,14 +203,19 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, /* Determine the new number of objects to index */ new_alloc = MAX(heap->nalloc * 2, (idx + 1)); + HDassert(idx < new_alloc); /* Reallocate array of objects */ if(NULL == (new_obj = H5FL_SEQ_REALLOC(H5HG_obj_t, heap->obj, new_alloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + /* Clear newly allocated space */ + HDmemset(&new_obj[heap->nalloc], 0, (new_alloc - heap->nalloc) * sizeof(heap->obj[0])); + /* Update heap information */ heap->nalloc = new_alloc; heap->obj = new_obj; + HDassert(heap->nalloc>heap->nused); } /* end if */ UINT16DECODE(p, heap->obj[idx].nrefs); @@ -220,16 +226,16 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, /* * The total storage size includes the size of the object header * and is zero padded so the next object header is properly - * aligned. The last bit of space is the free space object whose - * size is never padded and already includes the object header. + * aligned. The entire obj array was calloc'ed, so no need to zero + * the space here. The last bit of space is the free space object + * whose size is never padded and already includes the object + * header. */ if(idx > 0) { need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(heap->obj[idx].size); - /* Check for "gap" in index numbers (caused by deletions) and fill in heap object values */ - if(idx > (max_idx + 1)) - HDmemset(&heap->obj[max_idx + 1], 0, sizeof(H5HG_obj_t) * (idx - (max_idx + 1))); - max_idx = idx; + if(idx > max_idx) + max_idx = idx; } /* end if */ else need = heap->obj[idx].size; |