summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-04-02 04:22:59 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-04-02 04:22:59 (GMT)
commitea4271a3944e905ac2f4f5130e1e54df03e52ad6 (patch)
tree26a8509c67e6d12a8d78923ee73770abfe25e2cd
parent18264bf51c2e297efe6fedaf193e54802bc49904 (diff)
downloadhdf5-ea4271a3944e905ac2f4f5130e1e54df03e52ad6.zip
hdf5-ea4271a3944e905ac2f4f5130e1e54df03e52ad6.tar.gz
hdf5-ea4271a3944e905ac2f4f5130e1e54df03e52ad6.tar.bz2
[svn-r18500] Description:
Extract data structure 'destroy' routines from metadata cache client 'destroy' callbacks. Tested on: Mac OS X/32 10.6.3 (amazon) w/debug (h5committest not required on this branch)
-rw-r--r--src/H5Fpkg.h2
-rw-r--r--src/H5HG.c59
-rwxr-xr-xsrc/H5HGcache.c22
-rw-r--r--src/H5HGdbg.c12
-rw-r--r--src/H5HGpkg.h9
5 files changed, 50 insertions, 54 deletions
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index dc1efd8..58b177e 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -133,7 +133,7 @@ typedef struct H5F_file_t {
hbool_t latest_format; /* Always use the latest format? */
hbool_t store_msg_crt_idx; /* Store creation index for object header messages? */
hbool_t fam_to_sec2; /* Is h5repart changing driver from family to sec2? */
- int ncwfs; /* Num entries on cwfs list */
+ unsigned ncwfs; /* Num entries on cwfs list */
struct H5HG_heap_t **cwfs; /* Global heap cache */
struct H5G_t *root_grp; /* Open root group */
H5FO_t *open_objs; /* Open objects in file */
diff --git a/src/H5HG.c b/src/H5HG.c
index 4f495f1..8bf2dc5 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -226,8 +226,8 @@ HDmemset(heap->chunk, 0, size);
HDmemmove(f->shared->cwfs + 1, f->shared->cwfs,
MIN(f->shared->ncwfs, H5HG_NCWFS - 1) * sizeof(H5HG_heap_t *));
f->shared->cwfs[0] = heap;
- f->shared->ncwfs = MIN(H5HG_NCWFS, f->shared->ncwfs+1);
- }
+ f->shared->ncwfs = MIN(H5HG_NCWFS, f->shared->ncwfs + 1);
+ } /* end else */
/* Add the heap to the cache */
if(H5AC_set(f, dxpl_id, H5AC_GHEAP, addr, (size_t)size, heap, H5AC__NO_FLAGS_SET) < 0)
@@ -237,7 +237,7 @@ HDmemset(heap->chunk, 0, size);
done:
if(!(H5F_addr_defined(addr)) && heap)
- if(H5HG_dest(heap) < 0)
+ if(H5HG_free(heap) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy global heap collection")
FUNC_LEAVE_NOAPI(ret_value);
@@ -493,7 +493,7 @@ herr_t
H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/)
{
size_t need; /*total space needed for object */
- int cwfsno;
+ unsigned cwfsno;
size_t idx;
haddr_t addr = HADDR_UNDEF;
H5HG_heap_t *heap = NULL;
@@ -552,7 +552,7 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
if(!found) {
size_t new_need;
- for (cwfsno=0; cwfsno<f->shared->ncwfs; cwfsno++) {
+ for(cwfsno = 0; cwfsno < f->shared->ncwfs; cwfsno++) {
new_need = need;
new_need -= f->shared->cwfs[cwfsno]->obj[0].size;
new_need = MAX(f->shared->cwfs[cwfsno]->size, new_need);
@@ -576,7 +576,6 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
if(!H5F_addr_defined(addr))
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to allocate a global heap collection")
- cwfsno = 0;
} /* end if */
else {
/* Move the collection forward in the CWFS list, if it's not
@@ -670,13 +669,13 @@ H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/,
* with the H5AC_protect(), but it won't hurt to do it twice.
*/
if(heap->obj[0].begin) {
- int i;
+ unsigned u; /* Local index variable */
- for(i = 0; i < f->shared->ncwfs; i++)
- if(f->shared->cwfs[i] == heap) {
- if(i) {
- f->shared->cwfs[i] = f->shared->cwfs[i - 1];
- f->shared->cwfs[i - 1] = heap;
+ for(u = 0; u < f->shared->ncwfs; u++)
+ if(f->shared->cwfs[u] == heap) {
+ if(u) {
+ f->shared->cwfs[u] = f->shared->cwfs[u - 1];
+ f->shared->cwfs[u - 1] = heap;
} /* end if */
break;
} /* end if */
@@ -843,22 +842,20 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
flags |= H5AC__DELETED_FLAG; /* Indicate that the object was deleted, for the unprotect call */
} /* end if */
else {
- int i; /* Local index variable */
-
/*
* If the heap is in the CWFS list then advance it one position. The
* H5AC_protect() might have done that too, but that's okay. If the
* heap isn't on the CWFS list then add it to the end.
*/
- for(i = 0; i < f->shared->ncwfs; i++)
- if(f->shared->cwfs[i] == heap) {
- if(i) {
- f->shared->cwfs[i] = f->shared->cwfs[i - 1];
- f->shared->cwfs[i - 1] = heap;
+ for(u = 0; u < f->shared->ncwfs; u++)
+ if(f->shared->cwfs[u] == heap) {
+ if(u) {
+ f->shared->cwfs[u] = f->shared->cwfs[u - 1];
+ f->shared->cwfs[u - 1] = heap;
} /* end if */
break;
} /* end if */
- if(i >= f->shared->ncwfs) {
+ if(u >= f->shared->ncwfs) {
f->shared->ncwfs = MIN(f->shared->ncwfs + 1, H5HG_NCWFS);
f->shared->cwfs[f->shared->ncwfs - 1] = heap;
} /* end if */
@@ -873,7 +870,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5HG_dest
+ * Function: H5HG_free
*
* Purpose: Destroys a global heap collection in memory
*
@@ -882,29 +879,23 @@ done:
* Programmer: Quincey Koziol
* Wednesday, January 15, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
-H5HG_dest (H5HG_heap_t *heap)
+H5HG_free(H5HG_heap_t *heap)
{
- int i;
+ unsigned u; /* Local index variable */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HG_dest)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HG_free)
/* Check arguments */
HDassert(heap);
- /* Verify that node is clean */
- HDassert(heap->cache_info.is_dirty == FALSE);
-
-
/* Remove the heap from the CWFS list */
- for(i = 0; i < heap->shared->ncwfs; i++) {
- if(heap->shared->cwfs[i] == heap) {
+ for(u = 0; u < heap->shared->ncwfs; u++) {
+ if(heap->shared->cwfs[u] == heap) {
heap->shared->ncwfs -= 1;
- HDmemmove(heap->shared->cwfs + i, heap->shared->cwfs + i + 1, (heap->shared->ncwfs - i) * sizeof(H5HG_heap_t *));
+ HDmemmove(heap->shared->cwfs + u, heap->shared->cwfs + u + 1, (heap->shared->ncwfs - u) * sizeof(H5HG_heap_t *));
break;
} /* end if */
} /* end for */
@@ -916,5 +907,5 @@ H5HG_dest (H5HG_heap_t *heap)
heap = H5FL_FREE(H5HG_heap_t, heap);
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5HG_dest() */
+} /* H5HG_free() */
diff --git a/src/H5HGcache.c b/src/H5HGcache.c
index c99f97c..090e93c 100755
--- a/src/H5HGcache.c
+++ b/src/H5HGcache.c
@@ -125,7 +125,7 @@ H5HG_deserialize(haddr_t addr, size_t UNUSED len, const void *image,
size_t max_idx = 0; /* The maximum index seen */
H5HG_heap_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5HG_deserialize, NULL)
+ FUNC_ENTER_NOAPI_NOINIT(H5HG_deserialize)
/* check arguments */
HDassert(image);
@@ -165,7 +165,7 @@ H5HG_deserialize(haddr_t addr, size_t UNUSED len, const void *image,
/* Decode each object */
p = heap->chunk + H5HG_SIZEOF_HDR(f);
- nalloc = H5HG_NOBJS (f, heap->size);
+ nalloc = H5HG_NOBJS(f, heap->size);
/* 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.
*/
@@ -278,8 +278,8 @@ H5HG_deserialize(haddr_t addr, size_t UNUSED len, const void *image,
done:
if(!ret_value && heap)
- if(H5HG_dest(heap) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy global heap collection");
+ if(H5HG_free(heap) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy global heap collection")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HG_deserialize() */
@@ -309,8 +309,8 @@ H5HG_serialize(const H5F_t *f, hid_t UNUSED dxpl_id, haddr_t UNUSED addr,
/* Check arguments */
HDassert(f);
- HDassert(H5F_addr_defined (addr));
- HDassert(H5F_addr_eq (addr, heap->addr));
+ HDassert(H5F_addr_defined(addr));
+ HDassert(H5F_addr_eq(addr, heap->addr));
HDassert(heap);
/* Need to increase image size if we need to copy a bigger thing into it */
@@ -392,14 +392,18 @@ H5HG_image_len(const void *thing, size_t *image_len_ptr)
static herr_t
H5HG_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HG_free_icr)
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5HG_free_icr)
/* Check arguments */
HDassert(thing);
/* Destroy global heap collection */
- H5HG_dest(thing);
+ if(H5HG_free(thing) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy global heap")
- FUNC_LEAVE_NOAPI(SUCCEED)
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HG_free_icr() */
diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c
index 22b6008d..21d7647 100644
--- a/src/H5HGdbg.c
+++ b/src/H5HGdbg.c
@@ -67,13 +67,13 @@ H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
FUNC_ENTER_NOAPI(H5HG_debug, FAIL);
/* check arguments */
- assert(f);
- assert(H5F_addr_defined (addr));
- assert(stream);
- assert(indent >= 0);
- assert(fwidth >= 0);
+ HDassert(f);
+ HDassert(H5F_addr_defined (addr));
+ HDassert(stream);
+ HDassert(indent >= 0);
+ HDassert(fwidth >= 0);
- if (NULL == (h = (H5HG_heap_t *)H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, fwidth, f, H5AC_READ)))
+ if(NULL == (h = (H5HG_heap_t *)H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, (size_t)H5HG_SPEC_READ_SIZE, f, H5AC_READ)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load global heap collection");
fprintf(stream, "%*sGlobal Heap Collection...\n", indent, "");
diff --git a/src/H5HGpkg.h b/src/H5HGpkg.h
index d83d618..a7fac72 100644
--- a/src/H5HGpkg.h
+++ b/src/H5HGpkg.h
@@ -35,8 +35,6 @@
#include "H5ACprivate.h" /* Metadata cache */
#include "H5FLprivate.h" /* Free lists */
-#define H5F_PACKAGE
-#include "H5Fpkg.h"
/*****************************/
/* Package Private Variables */
@@ -131,6 +129,9 @@ typedef struct H5HG_obj_t {
uint8_t *begin; /*ptr to object into heap->chunk*/
} H5HG_obj_t;
+/* Forward declarations for fields */
+struct H5F_file_t;
+
struct H5HG_heap_t {
H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
/* first field in structure */
@@ -142,14 +143,14 @@ struct H5HG_heap_t {
/* If this value is >65535 then all indices */
/* have been used at some time and the */
/* correct new index should be searched for */
- H5F_file_t *shared; /* shared file */
+ struct H5F_file_t *shared; /* shared file */
H5HG_obj_t *obj; /*array of object descriptions */
};
/******************************/
/* Package Private Prototypes */
/******************************/
-H5_DLL herr_t H5HG_dest(H5HG_heap_t *heap);
+H5_DLL herr_t H5HG_free(H5HG_heap_t *heap);
#endif /* _H5HGpkg_H */