diff options
-rw-r--r-- | release_docs/RELEASE.txt | 4 | ||||
-rw-r--r-- | src/H5Distore.c | 114 | ||||
-rw-r--r-- | src/H5Fistore.c | 114 | ||||
-rw-r--r-- | src/H5Fprivate.h | 5 | ||||
-rw-r--r-- | src/H5Zdeflate.c | 12 |
5 files changed, 30 insertions, 219 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 02c9ab0..953f889 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -102,6 +102,10 @@ New Features Bug Fixes since HDF5-1.4.3 Release ================================== + * Fixed bug in chunking routines where they were using internal allocation + free routines, instead of malloc/free, preventing user filters from + working correctly. Chunks are now allocated/freed with malloc/free and + so should the chunks in user filters. QAK 2002/06/18 * Fixed bug where regular hyperslab selection could get incorrectly transferred when the number of elements in a row did not fit evenly into the buffer provided. QAK 2002/06/12 diff --git a/src/H5Distore.c b/src/H5Distore.c index 452399a..cbfa1bf 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -193,9 +193,6 @@ H5B_class_t H5B_ISTORE[1] = {{ #define H5F_HASH(F,ADDR) H5F_addr_hash((ADDR/H5F_HASH_DIVISOR),(F)->shared->rdcc.nslots) -/* Declare a free list to manage the chunk information */ -H5FL_BLK_DEFINE_STATIC(istore_chunk); - /* Declare a free list to manage H5F_rdcc_ent_t objects */ H5FL_DEFINE_STATIC(H5F_rdcc_ent_t); @@ -204,97 +201,6 @@ H5FL_ARR_DEFINE_STATIC(H5F_rdcc_ent_ptr_t,-1); /*------------------------------------------------------------------------- - * Function: H5F_istore_chunk_alloc - * - * Purpose: Allocates memory for a chunk of a dataset. This routine is used - * instead of malloc because the chunks can be kept on a free list so - * they don't thrash malloc/free as much. - * - * Return: Success: valid pointer to the chunk - * - * Failure: NULL - * - * Programmer: Quincey Koziol - * Tuesday, March 21, 2000 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void * -H5F_istore_chunk_alloc(size_t chunk_size) -{ - void *ret_value; /* Pointer to the chunk to return to the user */ - - FUNC_ENTER(H5F_istore_chunk_alloc, NULL); - - ret_value=H5FL_BLK_ALLOC(istore_chunk,(hsize_t)chunk_size,0); - - FUNC_LEAVE(ret_value); -} /* end H5F_istore_chunk_alloc() */ - - -/*------------------------------------------------------------------------- - * Function: H5F_istore_chunk_free - * - * Purpose: Releases memory for a chunk of a dataset. This routine is used - * instead of free because the chunks can be kept on a free list so - * they don't thrash malloc/free as much. - * - * Return: Success: NULL - * - * Failure: never fails - * - * Programmer: Quincey Koziol - * Tuesday, March 21, 2000 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void * -H5F_istore_chunk_free(void *chunk) -{ - FUNC_ENTER(H5F_istore_chunk_free, NULL); - - H5FL_BLK_FREE(istore_chunk,chunk); - - FUNC_LEAVE(NULL); -} /* end H5F_istore_chunk_free() */ - - -/*------------------------------------------------------------------------- - * Function: H5F_istore_chunk_realloc - * - * Purpose: Resizes a chunk in chunking memory allocation system. This - * does things the straightforward, simple way, not actually using - * realloc. - * - * Return: Success: NULL - * - * Failure: never fails - * - * Programmer: Quincey Koziol - * Tuesday, March 21, 2000 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void * -H5F_istore_chunk_realloc(void *chunk, size_t new_size) -{ - void *ret_value=NULL; /* Return value */ - - FUNC_ENTER(H5F_istore_chunk_realloc, NULL); - - ret_value=H5FL_BLK_REALLOC(istore_chunk,chunk,(hsize_t)new_size); - - FUNC_LEAVE(ret_value); -} /* end H5F_istore_chunk_realloc() */ - - -/*------------------------------------------------------------------------- * Function: H5F_istore_sizeof_rkey * * Purpose: Returns the size of a raw key for the specified UDATA. The @@ -978,7 +884,7 @@ H5F_istore_flush_entry(H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t reset) * for later. */ alloc = ent->chunk_size; - if (NULL==(buf = H5F_istore_chunk_alloc(alloc))) { + if (NULL==(buf = H5MM_malloc(alloc))) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline"); } @@ -1028,7 +934,7 @@ H5F_istore_flush_entry(H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t reset) ent->pline = H5O_free(H5O_PLINE, ent->pline); if (buf==ent->chunk) buf = NULL; if(ent->chunk!=NULL) - ent->chunk = H5F_istore_chunk_free(ent->chunk); + ent->chunk = H5MM_xfree(ent->chunk); } ret_value = SUCCEED; @@ -1036,7 +942,7 @@ H5F_istore_flush_entry(H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t reset) done: /* Free the temp buffer only if it's different than the entry chunk */ if (buf!=ent->chunk) - H5F_istore_chunk_free(buf); + H5MM_xfree(buf); /* * If we reached the point of no return then we have no choice but to @@ -1048,7 +954,7 @@ done: ent->layout = H5O_free(H5O_LAYOUT, ent->layout); ent->pline = H5O_free(H5O_PLINE, ent->pline); if(ent->chunk) - ent->chunk = H5F_istore_chunk_free(ent->chunk); + ent->chunk = H5MM_xfree(ent->chunk); } FUNC_LEAVE(ret_value); } @@ -1406,7 +1312,7 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, } H5_ASSIGN_OVERFLOW(chunk_size,tempchunk_size,hsize_t,size_t); chunk_alloc = chunk_size; - if (NULL==(chunk=H5F_istore_chunk_alloc (chunk_alloc))) { + if (NULL==(chunk=H5MM_malloc (chunk_alloc))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk"); } @@ -1426,7 +1332,7 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, udata.addr = HADDR_UNDEF; status = H5B_find (f, H5B_ISTORE, layout->addr, &udata); H5E_clear (); - if (NULL==(chunk = H5F_istore_chunk_alloc (chunk_alloc))) { + if (NULL==(chunk = H5MM_malloc (chunk_alloc))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk"); } @@ -1586,7 +1492,7 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, done: if (!ret_value) - H5F_istore_chunk_free (chunk); + H5MM_xfree (chunk); FUNC_LEAVE (ret_value); } @@ -1671,7 +1577,7 @@ H5F_istore_unlock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, H5F_istore_flush_entry (f, &x, TRUE); } else { if(chunk) - H5F_istore_chunk_free (chunk); + H5MM_xfree (chunk); } } else { /* @@ -2411,7 +2317,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, } /* Allocate chunk buffer for processes to use when writing fill values */ - if (NULL==(chunk = H5F_istore_chunk_alloc(chunk_size))) + if (NULL==(chunk = H5MM_malloc(chunk_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for chunk"); /* Fill the chunk with the proper values */ @@ -2486,7 +2392,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, done: /* Free the chunk for fill values */ if(chunk!=NULL) - H5F_istore_chunk_free(chunk); + H5MM_xfree(chunk); FUNC_LEAVE(ret_value); } diff --git a/src/H5Fistore.c b/src/H5Fistore.c index 452399a..cbfa1bf 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -193,9 +193,6 @@ H5B_class_t H5B_ISTORE[1] = {{ #define H5F_HASH(F,ADDR) H5F_addr_hash((ADDR/H5F_HASH_DIVISOR),(F)->shared->rdcc.nslots) -/* Declare a free list to manage the chunk information */ -H5FL_BLK_DEFINE_STATIC(istore_chunk); - /* Declare a free list to manage H5F_rdcc_ent_t objects */ H5FL_DEFINE_STATIC(H5F_rdcc_ent_t); @@ -204,97 +201,6 @@ H5FL_ARR_DEFINE_STATIC(H5F_rdcc_ent_ptr_t,-1); /*------------------------------------------------------------------------- - * Function: H5F_istore_chunk_alloc - * - * Purpose: Allocates memory for a chunk of a dataset. This routine is used - * instead of malloc because the chunks can be kept on a free list so - * they don't thrash malloc/free as much. - * - * Return: Success: valid pointer to the chunk - * - * Failure: NULL - * - * Programmer: Quincey Koziol - * Tuesday, March 21, 2000 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void * -H5F_istore_chunk_alloc(size_t chunk_size) -{ - void *ret_value; /* Pointer to the chunk to return to the user */ - - FUNC_ENTER(H5F_istore_chunk_alloc, NULL); - - ret_value=H5FL_BLK_ALLOC(istore_chunk,(hsize_t)chunk_size,0); - - FUNC_LEAVE(ret_value); -} /* end H5F_istore_chunk_alloc() */ - - -/*------------------------------------------------------------------------- - * Function: H5F_istore_chunk_free - * - * Purpose: Releases memory for a chunk of a dataset. This routine is used - * instead of free because the chunks can be kept on a free list so - * they don't thrash malloc/free as much. - * - * Return: Success: NULL - * - * Failure: never fails - * - * Programmer: Quincey Koziol - * Tuesday, March 21, 2000 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void * -H5F_istore_chunk_free(void *chunk) -{ - FUNC_ENTER(H5F_istore_chunk_free, NULL); - - H5FL_BLK_FREE(istore_chunk,chunk); - - FUNC_LEAVE(NULL); -} /* end H5F_istore_chunk_free() */ - - -/*------------------------------------------------------------------------- - * Function: H5F_istore_chunk_realloc - * - * Purpose: Resizes a chunk in chunking memory allocation system. This - * does things the straightforward, simple way, not actually using - * realloc. - * - * Return: Success: NULL - * - * Failure: never fails - * - * Programmer: Quincey Koziol - * Tuesday, March 21, 2000 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void * -H5F_istore_chunk_realloc(void *chunk, size_t new_size) -{ - void *ret_value=NULL; /* Return value */ - - FUNC_ENTER(H5F_istore_chunk_realloc, NULL); - - ret_value=H5FL_BLK_REALLOC(istore_chunk,chunk,(hsize_t)new_size); - - FUNC_LEAVE(ret_value); -} /* end H5F_istore_chunk_realloc() */ - - -/*------------------------------------------------------------------------- * Function: H5F_istore_sizeof_rkey * * Purpose: Returns the size of a raw key for the specified UDATA. The @@ -978,7 +884,7 @@ H5F_istore_flush_entry(H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t reset) * for later. */ alloc = ent->chunk_size; - if (NULL==(buf = H5F_istore_chunk_alloc(alloc))) { + if (NULL==(buf = H5MM_malloc(alloc))) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline"); } @@ -1028,7 +934,7 @@ H5F_istore_flush_entry(H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t reset) ent->pline = H5O_free(H5O_PLINE, ent->pline); if (buf==ent->chunk) buf = NULL; if(ent->chunk!=NULL) - ent->chunk = H5F_istore_chunk_free(ent->chunk); + ent->chunk = H5MM_xfree(ent->chunk); } ret_value = SUCCEED; @@ -1036,7 +942,7 @@ H5F_istore_flush_entry(H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t reset) done: /* Free the temp buffer only if it's different than the entry chunk */ if (buf!=ent->chunk) - H5F_istore_chunk_free(buf); + H5MM_xfree(buf); /* * If we reached the point of no return then we have no choice but to @@ -1048,7 +954,7 @@ done: ent->layout = H5O_free(H5O_LAYOUT, ent->layout); ent->pline = H5O_free(H5O_PLINE, ent->pline); if(ent->chunk) - ent->chunk = H5F_istore_chunk_free(ent->chunk); + ent->chunk = H5MM_xfree(ent->chunk); } FUNC_LEAVE(ret_value); } @@ -1406,7 +1312,7 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, } H5_ASSIGN_OVERFLOW(chunk_size,tempchunk_size,hsize_t,size_t); chunk_alloc = chunk_size; - if (NULL==(chunk=H5F_istore_chunk_alloc (chunk_alloc))) { + if (NULL==(chunk=H5MM_malloc (chunk_alloc))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk"); } @@ -1426,7 +1332,7 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, udata.addr = HADDR_UNDEF; status = H5B_find (f, H5B_ISTORE, layout->addr, &udata); H5E_clear (); - if (NULL==(chunk = H5F_istore_chunk_alloc (chunk_alloc))) { + if (NULL==(chunk = H5MM_malloc (chunk_alloc))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk"); } @@ -1586,7 +1492,7 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, done: if (!ret_value) - H5F_istore_chunk_free (chunk); + H5MM_xfree (chunk); FUNC_LEAVE (ret_value); } @@ -1671,7 +1577,7 @@ H5F_istore_unlock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, H5F_istore_flush_entry (f, &x, TRUE); } else { if(chunk) - H5F_istore_chunk_free (chunk); + H5MM_xfree (chunk); } } else { /* @@ -2411,7 +2317,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, } /* Allocate chunk buffer for processes to use when writing fill values */ - if (NULL==(chunk = H5F_istore_chunk_alloc(chunk_size))) + if (NULL==(chunk = H5MM_malloc(chunk_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for chunk"); /* Fill the chunk with the proper values */ @@ -2486,7 +2392,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, done: /* Free the chunk for fill values */ if(chunk!=NULL) - H5F_istore_chunk_free(chunk); + H5MM_xfree(chunk); FUNC_LEAVE(ret_value); } diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index d0ad3a2..6948852 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -320,11 +320,6 @@ __DLL__ hsize_t H5F_istore_allocated(H5F_t *f, unsigned ndims, haddr_t addr); __DLL__ herr_t H5F_istore_dump_btree(H5F_t *f, FILE *stream, unsigned ndims, haddr_t addr); -/* Functions for allocation/releasing chunks */ -__DLL__ void * H5F_istore_chunk_alloc(size_t chunk_size); -__DLL__ void * H5F_istore_chunk_realloc(void *chunk, size_t new_size); -__DLL__ void * H5F_istore_chunk_free(void *chunk); - /* Address-related functions */ __DLL__ void H5F_addr_encode(H5F_t *, uint8_t** /*in,out*/, haddr_t); __DLL__ void H5F_addr_decode(H5F_t *, const uint8_t** /*in,out*/, diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c index 9afdae3..7483bb2 100644 --- a/src/H5Zdeflate.c +++ b/src/H5Zdeflate.c @@ -83,7 +83,7 @@ H5Z_filter_deflate (unsigned UNUSED flags, size_t cd_nelmts, z_stream z_strm; size_t nalloc = *buf_size; - if (NULL==(outbuf = H5F_istore_chunk_alloc(nalloc))) { + if (NULL==(outbuf = H5MM_malloc(nalloc))) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate uncompression"); } @@ -104,7 +104,7 @@ H5Z_filter_deflate (unsigned UNUSED flags, size_t cd_nelmts, } if (Z_OK==status && 0==z_strm.avail_out) { nalloc *= 2; - if (NULL==(outbuf = H5F_istore_chunk_realloc(outbuf, nalloc))) { + if (NULL==(outbuf = H5MM_realloc(outbuf, nalloc))) { inflateEnd(&z_strm); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for deflate " @@ -115,7 +115,7 @@ H5Z_filter_deflate (unsigned UNUSED flags, size_t cd_nelmts, } } - H5F_istore_chunk_free(*buf); + H5MM_xfree(*buf); *buf = outbuf; outbuf = NULL; *buf_size = nalloc; @@ -133,7 +133,7 @@ H5Z_filter_deflate (unsigned UNUSED flags, size_t cd_nelmts, uLongf z_dst_nbytes = (uLongf)nbytes; uLong z_src_nbytes = (uLong)nbytes; - if (NULL==(z_dst=outbuf=H5F_istore_chunk_alloc(nbytes))) { + if (NULL==(z_dst=outbuf=H5MM_malloc(nbytes))) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate deflate destination buffer"); } @@ -146,7 +146,7 @@ H5Z_filter_deflate (unsigned UNUSED flags, size_t cd_nelmts, } else if (Z_OK!=status) { HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, 0, "deflate error"); } else { - H5F_istore_chunk_free(*buf); + H5MM_xfree(*buf); *buf = outbuf; outbuf = NULL; *buf_size = nbytes; @@ -160,6 +160,6 @@ H5Z_filter_deflate (unsigned UNUSED flags, size_t cd_nelmts, done: if(outbuf) - H5F_istore_chunk_free(outbuf); + H5MM_xfree(outbuf); FUNC_LEAVE (ret_value); } |