summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-05-01 05:16:50 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-05-01 05:16:50 (GMT)
commit65bb86375cfecac3e95ad1285db627a4a19eaabb (patch)
tree48151aa76db2a93929e682f3e7626d1b881364ca /src
parent59ea5ff28fb23ab4bd00f36da3268b2a0518c42c (diff)
downloadhdf5-65bb86375cfecac3e95ad1285db627a4a19eaabb.zip
hdf5-65bb86375cfecac3e95ad1285db627a4a19eaabb.tar.gz
hdf5-65bb86375cfecac3e95ad1285db627a4a19eaabb.tar.bz2
[svn-r383] ./src/H5A.c
./src/H5F.c ./src/H5G.c ./src/H5O.c ./src/H5Osdspace.c ./src/H5T.c ./src/H5Tconv.c ./src/H5Z.c ./test/big.c ./test/cmpd_dset.c ./test/dsets.c ./test/extend.c ./test/istore.c Now that I have a home-grown version of Purify I fixed all the leaks in all the test files.
Diffstat (limited to 'src')
-rw-r--r--src/H5A.c95
-rw-r--r--src/H5Epublic.h25
-rw-r--r--src/H5F.c8
-rw-r--r--src/H5G.c3
-rw-r--r--src/H5O.c13
-rw-r--r--src/H5Osdspace.c217
-rw-r--r--src/H5T.c7
-rw-r--r--src/H5Tconv.c2
-rw-r--r--src/H5Z.c2
9 files changed, 229 insertions, 143 deletions
diff --git a/src/H5A.c b/src/H5A.c
index f19732c..d9ba963 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -152,8 +152,6 @@ H5Acreate(hid_t loc_id, const char *name, hid_t datatype, hid_t dataspace,
H5T_t *type = NULL;
H5S_t *space = NULL;
const H5D_create_t *create_parms = NULL;
- H5A_t found_attr;
- intn seq=0;
hid_t ret_value = FAIL;
FUNC_ENTER(H5Acreate, FAIL);
@@ -191,20 +189,6 @@ H5Acreate(hid_t loc_id, const char *name, hid_t datatype, hid_t dataspace,
else
ent = H5G_entof ((H5G_t*)obj);
- /* Read in the existing attributes to check for duplicates */
- seq=0;
- while(H5O_read(ent, H5O_ATTR, seq, &found_attr)!=NULL)
- {
- /* Compare found attribute name to new attribute name reject creation if names are the same */
- if(HDstrcmp(found_attr.name,name)==0) {
- H5O_reset (H5O_ATTR, &found_attr);
- HRETURN_ERROR(H5E_ATTR, H5E_CANTCREATE, FAIL,
- "attribute already exists");
- }
- seq++;
- H5O_reset (H5O_ATTR, &found_attr);
- } /* end while */
-
/* Go do the real work for attaching the attribute to the dataset */
ret_value=H5A_create(ent,name,type,space);
@@ -236,6 +220,8 @@ static hid_t
H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type, const H5S_t *space)
{
H5A_t *attr = NULL;
+ H5A_t found_attr;
+ intn seq=0;
hid_t ret_value = FAIL;
FUNC_ENTER(H5A_create, FAIL);
@@ -253,6 +239,7 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type, const H5
attr->name=HDstrdup(name);
attr->dt=H5T_copy(type);
attr->ds=H5S_copy(space);
+ attr->initialized = TRUE; /*for now, set to false later*/
/* Copy the symbol table entry */
attr->ent=*ent;
@@ -268,6 +255,22 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type, const H5
}
attr->ent_opened=1;
+ /* Read in the existing attributes to check for duplicates */
+ seq=0;
+ while(H5O_read(&(attr->ent), H5O_ATTR, seq, &found_attr)!=NULL) {
+ /*
+ * Compare found attribute name to new attribute name reject creation
+ * if names are the same.
+ */
+ if(HDstrcmp(found_attr.name,attr->name)==0) {
+ H5O_reset (H5O_ATTR, &found_attr);
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTCREATE, FAIL,
+ "attribute already exists");
+ }
+ H5O_reset (H5O_ATTR, &found_attr);
+ seq++;
+ } /* end while */
+
/* Create the attribute message and save the attribute index */
if (H5O_modify(&(attr->ent), H5O_ATTR, H5O_NEW_MESG, 0, attr) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL,
@@ -279,6 +282,9 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type, const H5
"unable to register attribute for ID");
}
+ /* Now it's safe to say it's uninitialized */
+ attr->initialized = FALSE;
+
done:
if (ret_value < 0) {
if(attr)
@@ -322,21 +328,24 @@ H5A_get_index(H5G_entry_t *ent, const char *name)
/* Look up the attribute for the object */
i=0;
- while(H5O_read(ent, H5O_ATTR, i, &found_attr)!=NULL)
- {
- /* Compare found attribute name to new attribute name reject creation if names are the same */
- if(HDstrcmp(found_attr.name,name)==0) {
- H5O_reset (H5O_ATTR, &found_attr);
- ret_value=i;
- break;
- }
- H5O_reset (H5O_ATTR, &found_attr);
- i++;
- } /* end while */
+ while(H5O_read(ent, H5O_ATTR, i, &found_attr)!=NULL) {
+ /*
+ * Compare found attribute name to new attribute name reject creation
+ * if names are the same.
+ */
+ if(HDstrcmp(found_attr.name,name)==0) {
+ H5O_reset (H5O_ATTR, &found_attr);
+ ret_value = i;
+ break;
+ }
+ H5O_reset (H5O_ATTR, &found_attr);
+ i++;
+ } /* end while */
+
if(ret_value<0) {
HRETURN_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL,
"attribute not found");
- }
+ }
FUNC_LEAVE(ret_value);
} /* H5A_get_index() */
@@ -1111,9 +1120,9 @@ H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data)
/* Compare found attribute name to new attribute name reject creation if names are the same */
(*attr_num)++;
if((ret_value=op(loc_id,found_attr.name,op_data))!=0) {
- H5O_reset (H5O_ATTR, &found_attr);
+ H5O_reset (H5O_ATTR, &found_attr);
break;
- }
+ }
H5O_reset (H5O_ATTR, &found_attr);
} /* end while */
@@ -1172,18 +1181,20 @@ H5Adelete(hid_t loc_id, const char *name)
/* Look up the attribute for the object */
idx=0;
- while(H5O_read(ent, H5O_ATTR, idx, &found_attr)!=NULL)
- {
- /* Compare found attribute name to new attribute name reject creation if names are the same */
- if(HDstrcmp(found_attr.name,name)==0) {
- H5O_reset (H5O_ATTR, &found_attr);
- found=idx;
- break;
- }
- H5O_reset (H5O_ATTR, &found_attr);
- idx++;
- } /* end while */
- if(found<0) {
+ while(H5O_read(ent, H5O_ATTR, idx, &found_attr)!=NULL) {
+ /*
+ * Compare found attribute name to new attribute name reject
+ * creation if names are the same.
+ */
+ if(HDstrcmp(found_attr.name,name)==0) {
+ H5O_reset (H5O_ATTR, &found_attr);
+ found = idx;
+ break;
+ }
+ H5O_reset (H5O_ATTR, &found_attr);
+ idx++;
+ } /* end while */
+ if (found<0) {
HRETURN_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL,
"attribute not found");
}
diff --git a/src/H5Epublic.h b/src/H5Epublic.h
index 9a07ad5..85c7b60 100644
--- a/src/H5Epublic.h
+++ b/src/H5Epublic.h
@@ -23,6 +23,31 @@
#include <H5Ipublic.h>
/*
+ * One often needs to temporarily disable automatic error reporting when
+ * trying something that's likely or expected to fail. For instance, to
+ * determine if an object exists one can call H5Gstat() which will fail if
+ * the object doesn't exist. The code to try can be nested between calls to
+ * H5Eget_auto() and H5Eset_auto(), but it's easier just to use this macro
+ * like:
+ * H5E_BEGIN_TRY {
+ * ...stuff here that's likely to fail...
+ * } H5E_END_TRY
+ *
+ * Warning: don't break, return, or longjmp() from the body of the loop or
+ * the error reporting won't be properly restored!
+ */
+#define H5T_BEGIN_TRY do { \
+ herr_t (*H5E_saved_efunc)(void*); \
+ void *H5E_saved_edata; \
+ H5Eget_auto (&H5E_saved_efunc, &H5E_saved_edata); \
+ H5Eset_auto (NULL, NULL);
+
+#define H5T_END_TRY \
+ H5Eset_auto (H5E_saved_efunc, H5E_saved_edata); \
+}
+
+
+/*
* Declare an enumerated type which holds all the valid major HDF error codes.
*/
typedef enum H5E_major_t {
diff --git a/src/H5F.c b/src/H5F.c
index 7cd2cec..d726edf 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -537,11 +537,17 @@ H5F_dest(H5F_t *f)
if (f) {
if (0 == --(f->shared->nrefs)) {
- /* Do not close the root group since we didn't count it */
+ /*
+ * Do not close the root group since we didn't count it, but free
+ * the memory associated with it.
+ */
+ H5MM_xfree (f->shared->root_grp);
+ f->shared->root_grp=NULL;
if (H5AC_dest(f)) {
HERROR (H5E_FILE, H5E_CANTINIT, "problems closing file");
ret_value = FAIL; /*but keep going*/
}
+ f->shared->cwfs = H5MM_xfree (f->shared->cwfs);
f->shared = H5MM_xfree(f->shared);
}
f->name = H5MM_xfree(f->name);
diff --git a/src/H5G.c b/src/H5G.c
index 295828e..33338f4 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -1288,10 +1288,9 @@ H5G_close(H5G_t *grp)
if (H5O_close(&(grp->ent)) < 0) {
HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close");
}
+ H5MM_xfree (grp);
}
--grp->nref;
- if(grp->nref==0)
- H5MM_xfree(grp);
FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5O.c b/src/H5O.c
index 0c3a146..35dbe79 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -857,8 +857,8 @@ H5O_read(H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg)
"unable to read shared message from global heap");
}
tmp_mesg = (type->decode)(ent->file, tmp_buf, shared);
+ tmp_buf = H5MM_xfree (tmp_buf);
if (!tmp_mesg) {
- H5MM_xfree (tmp_buf);
HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
"unable to decode object header shared message");
}
@@ -1061,11 +1061,12 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
sh_mesg = H5MM_xcalloc (1, sizeof *sh_mesg);
if ((type->share)(ent->file, mesg, sh_mesg/*out*/)<0) {
/*
- * If the message isn't shared then turn of the shared bit
+ * If the message isn't shared then turn off the shared bit
* and treat it as an unshared message.
*/
H5E_clear ();
flags &= ~H5O_FLAG_SHARED;
+ H5MM_xfree (sh_mesg);
} else {
if (H5HG_link (ent->file, sh_mesg, 1)<0) {
HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL,
@@ -1098,6 +1099,9 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
if (flags & H5O_FLAG_SHARED) {
oh->mesg[idx].native = sh_mesg;
} else {
+ if (oh->mesg[idx].native) {
+ H5O_reset (oh->mesg[idx].type, oh->mesg[idx].native);
+ }
oh->mesg[idx].native = (type->copy) (mesg, oh->mesg[idx].native);
if (NULL == oh->mesg[idx].native) {
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
@@ -1601,8 +1605,9 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
oh->alloc_nmesgs += H5O_NMESGS;
oh->mesg = H5MM_xrealloc(oh->mesg,
oh->alloc_nmesgs * sizeof(H5O_mesg_t));
- /* Set new object header info to zeros */
- HDmemset(&oh->mesg[old_alloc],0,(oh->alloc_nmesgs-old_alloc)*sizeof(H5O_mesg_t));
+ /* Set new object header info to zeros */
+ HDmemset(&oh->mesg[old_alloc],0,
+ (oh->alloc_nmesgs-old_alloc)*sizeof(H5O_mesg_t));
}
null_idx = oh->nmesgs++;
oh->mesg[null_idx].type = H5O_NULL;
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 0073c9b..3a34fea 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -1,17 +1,17 @@
/****************************************************************************
-* NCSA HDF *
-* Software Development Group *
-* National Center for Supercomputing Applications *
-* University of Illinois at Urbana-Champaign *
-* 605 E. Springfield, Champaign IL 61820 *
-* *
-* For conditions of distribution and use, see the accompanying *
-* hdf/COPYING file. *
-* *
+* NCSA HDF *
+* Software Development Group *
+* National Center for Supercomputing Applications *
+* University of Illinois at Urbana-Champaign *
+* 605 E. Springfield, Champaign IL 61820 *
+* *
+* For conditions of distribution and use, see the accompanying *
+* hdf/COPYING file. *
+* *
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
@@ -22,7 +22,7 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5MMprivate.h>
#include <H5Oprivate.h>
-#define PABLO_MASK H5O_sdspace_mask
+#define PABLO_MASK H5O_sdspace_mask
/* PRIVATE PROTOTYPES */
static void *H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5HG_t *hobj);
@@ -31,19 +31,20 @@ static void *H5O_sdspace_copy(const void *_mesg, void *_dest);
static size_t H5O_sdspace_size(H5F_t *f, const void *_mesg);
static herr_t H5O_sdspace_debug(H5F_t *f, const void *_mesg,
FILE * stream, intn indent, intn fwidth);
+static herr_t H5O_sdspace_reset(void *_mesg);
/* This message derives from H5O */
const H5O_class_t H5O_SDSPACE[1] = {{
- H5O_SDSPACE_ID, /* message id number */
- "simple_dspace", /* message name for debugging */
- sizeof(H5S_simple_t), /* native message size */
- H5O_sdspace_decode, /* decode message */
- H5O_sdspace_encode, /* encode message */
- H5O_sdspace_copy, /* copy the native value */
- H5O_sdspace_size, /* size of symbol table entry */
- NULL, /* default reset method */
- NULL, /* no share method */
- H5O_sdspace_debug, /* debug the message */
+ H5O_SDSPACE_ID, /* message id number */
+ "simple_dspace", /* message name for debugging */
+ sizeof(H5S_simple_t), /* native message size */
+ H5O_sdspace_decode, /* decode message */
+ H5O_sdspace_encode, /* encode message */
+ H5O_sdspace_copy, /* copy the native value */
+ H5O_sdspace_size, /* size of symbol table entry */
+ H5O_sdspace_reset, /* default reset method */
+ NULL, /* no share method */
+ H5O_sdspace_debug, /* debug the message */
}};
/* Is the interface initialized? */
@@ -55,29 +56,29 @@ static hbool_t interface_initialize_g = FALSE;
H5O_sdspace_decode
PURPOSE
Decode a simple dimensionality message and return a pointer to a memory
- struct with the decoded information
+ struct with the decoded information
USAGE
void *H5O_sdspace_decode(f, raw_size, p)
- H5F_t *f; IN: pointer to the HDF5 file struct
- size_t raw_size; IN: size of the raw information buffer
- const uint8 *p; IN: the raw information buffer
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ size_t raw_size; IN: size of the raw information buffer
+ const uint8 *p; IN: the raw information buffer
RETURNS
Pointer to the new message in native order on success, NULL on failure
DESCRIPTION
- This function decodes the "raw" disk form of a simple dimensionality
+ This function decodes the "raw" disk form of a simple dimensionality
message into a struct in memory native format. The struct is allocated
within this function using malloc() and is returned to the caller.
MODIFICATIONS
- Robb Matzke, 1998-04-09
- The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes
- instead of just four bytes.
+ Robb Matzke, 1998-04-09
+ The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes
+ instead of just four bytes.
--------------------------------------------------------------------------*/
static void *
H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
{
H5S_simple_t *sdim = NULL;/* New simple dimensionality structure */
- intn u; /* local counting variable */
+ intn u; /* local counting variable */
uintn flags;
FUNC_ENTER(H5O_sdspace_decode, NULL);
@@ -89,31 +90,31 @@ H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
/* decode */
if ((sdim = H5MM_xcalloc(1, sizeof(H5S_simple_t))) != NULL) {
- UINT32DECODE(p, sdim->rank);
- UINT32DECODE(p, flags);
- if (sdim->rank > 0) {
- sdim->size = H5MM_xmalloc(sizeof(sdim->size[0]) * sdim->rank);
- for (u = 0; u < sdim->rank; u++) {
+ UINT32DECODE(p, sdim->rank);
+ UINT32DECODE(p, flags);
+ if (sdim->rank > 0) {
+ sdim->size = H5MM_xmalloc(sizeof(sdim->size[0]) * sdim->rank);
+ for (u = 0; u < sdim->rank; u++) {
H5F_decode_length (f, p, sdim->size[u]);
}
- if (flags & 0x01) {
- sdim->max = H5MM_xmalloc(sizeof(sdim->max[0]) * sdim->rank);
- for (u = 0; u < sdim->rank; u++) {
+ if (flags & 0x01) {
+ sdim->max = H5MM_xmalloc(sizeof(sdim->max[0]) * sdim->rank);
+ for (u = 0; u < sdim->rank; u++) {
H5F_decode_length (f, p, sdim->max[u]);
}
- }
- if (flags & 0x02) {
- sdim->perm = H5MM_xmalloc(sizeof(sdim->perm[0]) * sdim->rank);
- for (u = 0; u < sdim->rank; u++)
- UINT32DECODE(p, sdim->perm[u]);
- }
- }
+ }
+ if (flags & 0x02) {
+ sdim->perm = H5MM_xmalloc(sizeof(sdim->perm[0]) * sdim->rank);
+ for (u = 0; u < sdim->rank; u++)
+ UINT32DECODE(p, sdim->perm[u]);
+ }
+ }
}
#ifdef LATER
done:
#endif /* LATER */
- if (sdim == NULL) { /* Error condition cleanup */
+ if (sdim == NULL) { /* Error condition cleanup */
}
/* Normal function cleanup */
@@ -127,26 +128,26 @@ H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5HG_t __unused__ *hobj)
Encode a simple dimensionality message
USAGE
herr_t H5O_sdspace_encode(f, raw_size, p, mesg)
- H5F_t *f; IN: pointer to the HDF5 file struct
- size_t raw_size; IN: size of the raw information buffer
- const uint8 *p; IN: the raw information buffer
- const void *mesg; IN: Pointer to the simple dimensionality struct
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ size_t raw_size; IN: size of the raw information buffer
+ const uint8 *p; IN: the raw information buffer
+ const void *mesg; IN: Pointer to the simple dimensionality struct
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function encodes the native memory form of the simple
+ This function encodes the native memory form of the simple
dimensionality message in the "raw" disk form.
MODIFICATIONS
- Robb Matzke, 1998-04-09
- The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes
- instead of just four bytes.
+ Robb Matzke, 1998-04-09
+ The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes
+ instead of just four bytes.
--------------------------------------------------------------------------*/
static herr_t
H5O_sdspace_encode(H5F_t *f, uint8 *p, const void *mesg)
{
- const H5S_simple_t *sdim = (const H5S_simple_t *) mesg;
- intn u; /* Local counting variable */
+ const H5S_simple_t *sdim = (const H5S_simple_t *) mesg;
+ intn u; /* Local counting variable */
uintn flags = 0;
FUNC_ENTER(H5O_sdspace_encode, FAIL);
@@ -164,18 +165,18 @@ H5O_sdspace_encode(H5F_t *f, uint8 *p, const void *mesg)
UINT32ENCODE(p, sdim->rank);
UINT32ENCODE(p, flags);
if (sdim->rank > 0) {
- for (u = 0; u < sdim->rank; u++) {
+ for (u = 0; u < sdim->rank; u++) {
H5F_encode_length (f, p, sdim->size[u]);
}
- if (flags & 0x01) {
- for (u = 0; u < sdim->rank; u++) {
+ if (flags & 0x01) {
+ for (u = 0; u < sdim->rank; u++) {
H5F_encode_length (f, p, sdim->max[u]);
}
- }
- if (flags & 0x02) {
- for (u = 0; u < sdim->rank; u++)
- UINT32ENCODE(p, sdim->perm[u]);
- }
+ }
+ if (flags & 0x02) {
+ for (u = 0; u < sdim->rank; u++)
+ UINT32ENCODE(p, sdim->perm[u]);
+ }
}
FUNC_LEAVE(SUCCEED);
}
@@ -187,46 +188,76 @@ H5O_sdspace_encode(H5F_t *f, uint8 *p, const void *mesg)
Copies a message from MESG to DEST, allocating DEST if necessary.
USAGE
void *H5O_sdspace_copy(mesg, dest)
- const void *mesg; IN: Pointer to the source simple dimensionality struct
- const void *dest; IN: Pointer to the destination simple dimensionality struct
+ const void *mesg; IN: Pointer to the source simple dimensionality struct
+ const void *dest; IN: Pointer to the destination simple dimensionality struct
RETURNS
Pointer to DEST on success, NULL on failure
DESCRIPTION
- This function copies a native (memory) simple dimensionality message,
+ This function copies a native (memory) simple dimensionality message,
allocating the destination structure if necessary.
--------------------------------------------------------------------------*/
-static void *
+static void *
H5O_sdspace_copy(const void *mesg, void *dest)
{
- const H5S_simple_t *src = (const H5S_simple_t *) mesg;
- H5S_simple_t *dst = (H5S_simple_t *) dest;
+ const H5S_simple_t *src = (const H5S_simple_t *) mesg;
+ H5S_simple_t *dst = (H5S_simple_t *) dest;
FUNC_ENTER(H5O_sdspace_copy, NULL);
/* check args */
assert(src);
if (!dst)
- dst = H5MM_xcalloc(1, sizeof(H5S_simple_t));
+ dst = H5MM_xcalloc(1, sizeof(H5S_simple_t));
/* deep copy -- pointed-to values are copied also */
HDmemcpy(dst, src, sizeof(H5S_simple_t));
if (src->size) {
- dst->size = H5MM_xcalloc(src->rank, sizeof(src->size[0]));
+ dst->size = H5MM_xcalloc(src->rank, sizeof(src->size[0]));
HDmemcpy (dst->size, src->size, src->rank*sizeof(src->size[0]));
}
if (src->max) {
- dst->max = H5MM_xcalloc(src->rank, sizeof(src->max[0]));
+ dst->max = H5MM_xcalloc(src->rank, sizeof(src->max[0]));
HDmemcpy (dst->max, src->max, src->rank*sizeof(src->max[0]));
}
if (src->perm) {
- dst->perm = H5MM_xcalloc(src->rank, sizeof(src->perm[0]));
+ dst->perm = H5MM_xcalloc(src->rank, sizeof(src->perm[0]));
HDmemcpy (dst->perm, src->perm, src->rank*sizeof(src->perm[0]));
}
FUNC_LEAVE((void *) dst);
}
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_sdspace_reset
+ *
+ * Purpose: Frees the inside of a dataspace message and resets it to some
+ * initial value.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, April 30, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_sdspace_reset(void *_mesg)
+{
+ H5S_simple_t *mesg = (H5S_simple_t*)_mesg;
+
+ FUNC_ENTER (H5O_sdspace_reset, FAIL);
+ mesg->size = H5MM_xfree (mesg->size);
+ mesg->max = H5MM_xfree (mesg->max);
+ mesg->perm = H5MM_xfree (mesg->perm);
+ FUNC_LEAVE (SUCCEED);
+}
+
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_size
@@ -234,29 +265,29 @@ H5O_sdspace_copy(const void *mesg, void *dest)
Return the raw message size in bytes
USAGE
void *H5O_sdspace_copy(f, mesg)
- H5F_t *f; IN: pointer to the HDF5 file struct
- const void *mesg; IN: Pointer to the source simple dimensionality struct
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ const void *mesg; IN: Pointer to the source simple dimensionality struct
RETURNS
Size of message on success, zero on failure
DESCRIPTION
- This function returns the size of the raw simple dimensionality message on
+ This function returns the size of the raw simple dimensionality message on
success. (Not counting the message type or size fields, only the data
portion of the message). It doesn't take into account alignment.
MODIFICATIONS
- Robb Matzke, 1998-04-09
- The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes
- instead of just four bytes.
+ Robb Matzke, 1998-04-09
+ The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes
+ instead of just four bytes.
--------------------------------------------------------------------------*/
static size_t
H5O_sdspace_size(H5F_t *f, const void *mesg)
{
- const H5S_simple_t *sdim = (const H5S_simple_t *) mesg;
+ const H5S_simple_t *sdim = (const H5S_simple_t *) mesg;
/*
* all dimensionality messages are at least 8 bytes long (four bytes for
* rank and four bytes for flags)
*/
- size_t ret_value = 8;
+ size_t ret_value = 8;
FUNC_ENTER(H5O_sdspace_size, 0);
@@ -279,23 +310,23 @@ H5O_sdspace_size(H5F_t *f, const void *mesg)
Prints debugging information for a simple dimensionality message
USAGE
void *H5O_sdspace_debug(f, mesg, stream, indent, fwidth)
- H5F_t *f; IN: pointer to the HDF5 file struct
- const void *mesg; IN: Pointer to the source simple dimensionality struct
- FILE *stream; IN: Pointer to the stream for output data
- intn indent; IN: Amount to indent information by
- intn fwidth; IN: Field width (?)
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ const void *mesg; IN: Pointer to the source simple dimensionality struct
+ FILE *stream; IN: Pointer to the stream for output data
+ intn indent; IN: Amount to indent information by
+ intn fwidth; IN: Field width (?)
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function prints debugging output to the stream passed as a
+ This function prints debugging output to the stream passed as a
parameter.
--------------------------------------------------------------------------*/
static herr_t
H5O_sdspace_debug(H5F_t __unused__ *f, const void *mesg,
FILE * stream, intn indent, intn fwidth)
{
- const H5S_simple_t *sdim = (const H5S_simple_t *) mesg;
- intn u; /* local counting variable */
+ const H5S_simple_t *sdim = (const H5S_simple_t *) mesg;
+ intn u; /* local counting variable */
FUNC_ENTER(H5O_sdspace_debug, FAIL);
@@ -307,8 +338,8 @@ H5O_sdspace_debug(H5F_t __unused__ *f, const void *mesg,
assert(fwidth >= 0);
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Rank:",
- (unsigned long) (sdim->rank));
+ "Rank:",
+ (unsigned long) (sdim->rank));
HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:");
for (u = 0; u < sdim->rank; u++) {
@@ -319,7 +350,7 @@ H5O_sdspace_debug(H5F_t __unused__ *f, const void *mesg,
HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Dim Max:");
if (sdim->max) {
HDfprintf (stream, "{");
- for (u = 0; u < sdim->rank; u++) {
+ for (u = 0; u < sdim->rank; u++) {
if (H5S_UNLIMITED==sdim->max[u]) {
HDfprintf (stream, "%sINF", u?", ":"");
} else {
diff --git a/src/H5T.c b/src/H5T.c
index c2c6d9f..8648a4e 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -342,6 +342,8 @@ H5T_term_interface(void)
path->cdata.stats->timer.etime,
nbytes / path->cdata.stats->timer.etime);
#endif
+ H5T_close (path->src);
+ H5T_close (path->dst);
H5MM_xfree (path->cdata.stats);
}
}
@@ -2765,7 +2767,10 @@ H5T_close(H5T_t *dt)
assert(dt);
- /* Don't free locked datatypes unless we are shutting the interface down */
+ /*
+ * Don't free locked datatypes unless we are shutting the interface
+ * down.
+ */
if (!dt->locked) {
if (dt && H5T_COMPOUND == dt->type) {
for (i = 0; i < dt->u.compnd.nmembs; i++) {
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index be07341..9a0f833 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -62,6 +62,7 @@ H5T_conv_noop(hid_t __unused__ src_id, hid_t __unused__ dst_id,
case H5T_CONV_FREE:
/* Nothing to free */
+ cdata->stats = H5MM_xfree (cdata->stats);
break;
default:
@@ -387,6 +388,7 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
H5MM_xfree (priv->src_memb_id);
H5MM_xfree (priv->dst_memb_id);
H5MM_xfree (priv->memb_conv);
+ H5MM_xfree (priv->memb_cdata);
cdata->priv = priv = H5MM_xfree (priv);
break;
diff --git a/src/H5Z.c b/src/H5Z.c
index 5c7f0fa..8a28f54 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -160,7 +160,9 @@ H5Z_term_interface (void)
HDfprintf (stderr, "%9s\n", "NaN");
}
}
+ H5MM_xfree (H5Z_g[i].name);
}
+ HDmemset (H5Z_g, 0, sizeof H5Z_g);
#endif
}