summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-02-19 20:18:55 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-02-19 20:18:55 (GMT)
commit1bcb5fd93698a7491fae309c0a9a5006d2a560b4 (patch)
tree39bd2cf8e75280661f08706e0157c109be974fb6 /src
parentcaee4e9f6f5a5d421a8410422cce09419a72de70 (diff)
downloadhdf5-1bcb5fd93698a7491fae309c0a9a5006d2a560b4.zip
hdf5-1bcb5fd93698a7491fae309c0a9a5006d2a560b4.tar.gz
hdf5-1bcb5fd93698a7491fae309c0a9a5006d2a560b4.tar.bz2
[svn-r294] Changes since 19980219
---------------------- ./src/H5A.c ./src/H5C.c Objects are removed from the group when there reference count hits zero regardless of whether H5A knows how to free the object. ./src/debug.c ./test/tstab.c Changed a zero to H5C_DEFAULT.
Diffstat (limited to 'src')
-rw-r--r--src/H5A.c61
-rw-r--r--src/H5C.c11
-rw-r--r--src/debug.c3
3 files changed, 45 insertions, 30 deletions
diff --git a/src/H5A.c b/src/H5A.c
index bc8858f..f7f7449 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -554,44 +554,59 @@ H5A_remove(hid_t atm /* IN: Atom to remove */
FUNC_LEAVE(ret_value);
}
-/******************************************************************************
- NAME
- H5A_dec_ref - Decrements a reference to a reference counted atom.
- IN: Atom to decrement reference count for
- DESCRIPTION
- Decrements the number of references outstanding for an atom. This will
- fail if the group is not a reference counted group. The atom group's
- 'free' function will be called for the atom if the reference count for the
- atom reaches 0.
-
- RETURNS
- SUCCEED/FAIL
-
-*******************************************************************************/
+
+/*-------------------------------------------------------------------------
+ * Function: H5A_dec_ref
+ *
+ * Purpose: Decrements the number of references outstanding for an atom.
+ * This will fail if the group is not a reference counted group.
+ * The atom group's 'free' function will be called for the atom
+ * if the reference count for the atom reaches 0 and a free
+ * function has been defined at group creation time.
+ *
+ * Return: Success: New reference count.
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Unknown
+ *
+ * Modifications:
+ *
+ * Robb Matzke, 19 Feb 1998
+ * It is no longer an error when the reference count of an item reaches
+ * zero and no `free' function has been defined. The object is still
+ * removed from the list.
+ *
+ *-------------------------------------------------------------------------
+ */
intn
H5A_dec_ref(hid_t atm)
{
- group_t grp = ATOM_TO_GROUP(atm); /* Group the object is in */
- atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
- atom_info_t *atm_ptr = NULL; /* ptr to the new atom */
- const void * obj; /* object to call 'free' function with */
- intn ret_value = FAIL;
+ group_t grp = ATOM_TO_GROUP(atm); /* Group the object is in */
+ atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
+ atom_info_t *atm_ptr = NULL; /* ptr to the new atom */
+ const void * obj; /* object to call 'free' function with */
+ intn ret_value = FAIL;
FUNC_ENTER(H5A_dec_ref, FAIL);
grp_ptr = atom_group_list[grp];
- if (grp_ptr == NULL || grp_ptr->count <= 0 || grp_ptr->free_func == NULL) {
+ if (grp_ptr == NULL || grp_ptr->count <= 0) {
HRETURN(FAIL);
}
+
/* General lookup of the atom */
if ((atm_ptr = H5A_find_atom(atm)) != NULL) {
/* Decrement the reference count */
- atm_ptr->count--;
+ ret_value = --(atm_ptr->count);
/* If the reference count is zero, remove the object from the group */
if (0 == atm_ptr->count && (obj = H5A_remove(atm)) != NULL) {
- /* call the user's 'free' function for the atom's information */
- (*grp_ptr->free_func) ((void *)obj);
+ /*
+ * call the user's 'free' function for the atom's information,
+ * otherwise just leak memory.
+ */
+ if (*grp_ptr->free_func) (*grp_ptr->free_func)((void *)obj);
}
ret_value = SUCCEED;
}
diff --git a/src/H5C.c b/src/H5C.c
index e04425e..d549289 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -251,13 +251,12 @@ H5Cclose(hid_t tid)
}
/*
- * Chuck the object! This will fail when the reference count reaches zero
- * since there is no free func registered for the property list groups.
+ * Chuck the object! When the reference count reaches zero then
+ * H5A_dec_ref() removes it from the group and we should free it. The
+ * free function is not registered as part of the group because it takes
+ * an extra argument.
*/
- if (H5A_dec_ref (tid)<0) {
- H5ECLEAR;
- H5C_close (type, tmpl);
- }
+ if (0==H5A_dec_ref(tid)) H5C_close (type, tmpl);
FUNC_LEAVE (SUCCEED);
}
diff --git a/src/debug.c b/src/debug.c
index b5ea511..8356de7 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -17,6 +17,7 @@
#include <H5private.h>
#include <H5Aprivate.h>
#include <H5Bprivate.h>
+#include <H5Cprivate.h>
#include <H5Fprivate.h>
#include <H5Gprivate.h>
#include <H5Hprivate.h>
@@ -56,7 +57,7 @@ main(int argc, char *argv[])
/*
* Open the file and get the file descriptor.
*/
- if ((fid = H5Fopen(argv[1], 0, 0)) < 0) {
+ if ((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, H5C_DEFAULT)) < 0) {
fprintf(stderr, "cannot open file\n");
HDexit(1);
}