diff options
-rw-r--r-- | release_docs/RELEASE.txt | 4 | ||||
-rw-r--r-- | src/H5Distore.c | 116 | ||||
-rw-r--r-- | src/H5Fistore.c | 116 | ||||
-rw-r--r-- | src/H5Fprivate.h | 5 | ||||
-rw-r--r-- | src/H5Zdeflate.c | 12 |
5 files changed, 32 insertions, 221 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 586d1e4..aa608a3 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -35,6 +35,10 @@ Bug Fixes since HDF5-1.4.0 Library ------- + * 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 03fd598..913bdf9 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -191,9 +191,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); @@ -202,97 +199,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_NOAPI(H5F_istore_chunk_alloc, NULL); - - ret_value=H5FL_BLK_ALLOC(istore_chunk,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_NOAPI(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_NOAPI(H5F_istore_chunk_realloc, NULL); - - ret_value=H5FL_BLK_REALLOC(istore_chunk,chunk,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 @@ -1016,7 +922,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"); } @@ -1060,7 +966,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; @@ -1068,7 +974,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 @@ -1080,7 +986,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); } @@ -1131,7 +1037,7 @@ H5F_istore_preempt(H5F_t *f, H5F_rdcc_ent_t * ent, hbool_t flush) ent->layout = H5O_free(H5O_LAYOUT, ent->layout); ent->pline = H5O_free(H5O_PLINE, ent->pline); if(ent->chunk != NULL) - ent->chunk = H5F_istore_chunk_free(ent->chunk); + ent->chunk = H5MM_xfree(ent->chunk); } @@ -1467,7 +1373,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"); } @@ -1487,7 +1393,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"); } @@ -1645,7 +1551,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); } @@ -1731,7 +1637,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 { /* @@ -2490,7 +2396,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, /* Check if fill values should be written to blocks */ if(fill_time != H5D_FILL_TIME_NEVER) { /* 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 */ @@ -2569,7 +2475,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 03fd598..913bdf9 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -191,9 +191,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); @@ -202,97 +199,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_NOAPI(H5F_istore_chunk_alloc, NULL); - - ret_value=H5FL_BLK_ALLOC(istore_chunk,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_NOAPI(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_NOAPI(H5F_istore_chunk_realloc, NULL); - - ret_value=H5FL_BLK_REALLOC(istore_chunk,chunk,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 @@ -1016,7 +922,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"); } @@ -1060,7 +966,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; @@ -1068,7 +974,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 @@ -1080,7 +986,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); } @@ -1131,7 +1037,7 @@ H5F_istore_preempt(H5F_t *f, H5F_rdcc_ent_t * ent, hbool_t flush) ent->layout = H5O_free(H5O_LAYOUT, ent->layout); ent->pline = H5O_free(H5O_PLINE, ent->pline); if(ent->chunk != NULL) - ent->chunk = H5F_istore_chunk_free(ent->chunk); + ent->chunk = H5MM_xfree(ent->chunk); } @@ -1467,7 +1373,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"); } @@ -1487,7 +1393,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"); } @@ -1645,7 +1551,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); } @@ -1731,7 +1637,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 { /* @@ -2490,7 +2396,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, /* Check if fill values should be written to blocks */ if(fill_time != H5D_FILL_TIME_NEVER) { /* 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 */ @@ -2569,7 +2475,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 c18c331..6c7e913 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -400,11 +400,6 @@ __DLL__ herr_t H5F_istore_initialize_by_extent( H5F_t *f, const struct H5O_layout_t *layout, struct H5P_genplist_t *dc_plist, const struct H5S_t *space ); -/* 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 57cabb3..3f43310 100644 --- a/src/H5Zdeflate.c +++ b/src/H5Zdeflate.c @@ -72,7 +72,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"); } @@ -93,7 +93,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 " @@ -104,7 +104,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; @@ -122,7 +122,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"); } @@ -135,7 +135,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; @@ -149,6 +149,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); } |