diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-03-25 03:51:41 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-03-25 03:51:41 (GMT) |
commit | 42efc1c2b591e4cd45ec6cb3bdf32044343118d2 (patch) | |
tree | 0ab542871c32246199479e8933ff26286aaf629a /src/H5HG.c | |
parent | 3360c3af0c100ac4d3a2fe2865f34661da862ec5 (diff) | |
download | hdf5-42efc1c2b591e4cd45ec6cb3bdf32044343118d2.zip hdf5-42efc1c2b591e4cd45ec6cb3bdf32044343118d2.tar.gz hdf5-42efc1c2b591e4cd45ec6cb3bdf32044343118d2.tar.bz2 |
[svn-r18451] Description:
Bring r18172:18446 from trunk to revise_chunks branch.
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 (amani) 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
Diffstat (limited to 'src/H5HG.c')
-rw-r--r-- | src/H5HG.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -640,10 +640,11 @@ void * H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/, size_t *buf_size) { - H5HG_heap_t *heap = NULL; - size_t size; - uint8_t *p = NULL; - void *ret_value; + H5HG_heap_t *heap = NULL; /* Pointer to global heap object */ + size_t size; /* Size of the heap object */ + uint8_t *p; /* Pointer to object in heap buffer */ + void *orig_object = object; /* Keep a copy of the original object pointer */ + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5HG_read, NULL) @@ -659,6 +660,7 @@ H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/, HDassert(heap->obj[hobj->idx].begin); size = heap->obj[hobj->idx].size; p = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR(f); + /* Allocate a buffer for the object read in, if the user didn't give one */ if(!object && NULL == (object = H5MM_malloc(size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") @@ -692,6 +694,9 @@ done: if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET)<0) HDONE_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header") + if(NULL == ret_value && NULL == orig_object && object) + H5MM_free(object); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HG_read() */ |