summaryrefslogtreecommitdiffstats
path: root/src/H5G.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1997-11-14 14:42:14 (GMT)
committerRobb Matzke <matzke@llnl.gov>1997-11-14 14:42:14 (GMT)
commitcdeeb5553a3920565d87201761dadd1fe32aa3b1 (patch)
treea209c61f85983c1a76bf5c65d1f3285c4861ec46 /src/H5G.c
parent73897627660169de753597b9ff045d3112646506 (diff)
downloadhdf5-cdeeb5553a3920565d87201761dadd1fe32aa3b1.zip
hdf5-cdeeb5553a3920565d87201761dadd1fe32aa3b1.tar.gz
hdf5-cdeeb5553a3920565d87201761dadd1fe32aa3b1.tar.bz2
[svn-r136] ./MANIFEST
./src/Makefile.in Added H5Ffamily.c and H5Fsplit.c ./src/H5B.c ./src/H5Bprivate.h ./src/H5Gnode.c Added `const' to sublass arguments. ./src/H5F.c ./src/H5Flow.c ./src/H5Fsec2.c Make sure file buffers get flushed during a call to H5Fflush(). Check for overflow in address encoding and decoding. ./src/H5Ffam.c ./src/H5Fprivate.c ./test/istore.c Implementation of file families so 32-bit machines can access 64-bit files. ./src/H5Oprivate.h Removed H5O_NO_ADDR constant. ./config/freebsd2.2.1 ./config/linux Added -DH5G_DEBUG and -DH5F_DEBUG to the list of debugging flags. ./html/H5.format.html Changed some <offset>-sized things to <length>-sized things. ./src/H5AC.c ./src/H5ACprivate.h ./src/H5B.c ./src/H5Bprivate.h ./src/H5C.c ./src/H5D.c ./src/H5F.c ./src/H5Fcore.c ./src/H5Fistore.c ./src/H5Flow.c ./src/H5Fprivate.h ./src/H5Fsec2.c ./src/H5Fstdio.c ./src/H5G.c ./src/H5Gent.c ./src/H5Gnode.c ./src/H5Gpkg.h ./src/H5Gprivate.h ./src/H5Gshad.c ./src/H5Gstab.c ./src/H5H.c ./src/H5Hprivate.h ./src/H5MF.c ./src/H5MFprivate.h ./src/H5O.c ./src/H5Ocont.c ./src/H5Oistore.c ./src/H5Oprivate.h ./src/H5Ostab.c ./src/H5Ostdst.c ./src/H5pivate.h ./src/debug.c ./test/istore.c ./test/theap.c ./test/tohdr.c ./test/tstab.c Lots of changes caused by generalizing addresses. The haddr_t is now a struct, so you can no longer perform arithmetic on it. But since it's small, simple, and often used, storage is allocated like with an integer. But we always pass them around by reference. That is, when using an address in another struct, allocate space: struct my_struct { char *name; haddr_t address; } x; But when passing it to a function, pass by reference: H5F_addr_print (stderr, &(x.address)); Addresses should be initialized with H5F_addr_undef (&(x.address)); Functions for operating on addresses are in H5Flow.c and begin with H5F_addr_... Functions never return haddr_t or haddr_t*; they always pass them through arguments instead. A function that returns an address through an argument does so with its last argument and it is marked with `/*out*/'. Calls to such functions also mark output-only arguments with `/*out*/' ./src/H5Fsplit.c (new) A two-member family where all meta data goes in the first member and all raw data goes in the second member. ./src/H5B.c ./src/H5D.c ./src/H5F.c ./src/H5Ffamily.c ./src/H5Fistore.c ./src/H5Flow.c ./src/H5Fprivate.h ./src/H5Fsec2.c ./src/H5Fstdio.c ./src/H5Gnode.c ./src/H5H.c ./src/H5MF.c ./src/H5MFprivate.h ./src/H5O.c Differentiate between meta data storage and raw data storage. Provide a mechanism so that the file driver can extend the file to allocate more memory. ./src/H5E.c ./src/H5Epublic.c Added the error H5E_TRUNCATED to be reported when the file is shorter than the length recorded in the boot block. ./src/H5F.c Added H5F_locate_signature() so we only do it in one place now. ./INSTALL ./INSTALL_MAINT Just a couple clarifications. ./html/ExternalFiles.html ./html/storage.html Documents how external files work. ./test/hyperslab.c ./test/istore.c Fixed printf's on 64-bit machines. ./test/istore.c Added ifdef's to test the split file driver.
Diffstat (limited to 'src/H5G.c')
-rw-r--r--src/H5G.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/src/H5G.c b/src/H5G.c
index c251b14..5c1e2cd 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -426,13 +426,15 @@ H5G_basename (const char *name, size_t *size_p)
*
* As a special case, if the NAME is the name `/' (or
* equivalent) then GRP_ENT is initialized to all zero
- * and a pointer to the root symbol table entry is returned.
+ * and an invalid header address and a pointer to the root
+ * symbol table entry is returned.
*
* As a special case, if the NAME is the string `/foo' (or
* equivalent) and the root symbol table entry points to a
* non-group object with a name message with the value
- * `foo' then GRP_ENT is initialized to all zero and a pointer
- * to the root symbol table entry is returned.
+ * `foo' then GRP_ENT is initialized to all zero (except for an
+ * invalid header address) and a pointer to the root symbol
+ * table entry is returned.
*
* Errors:
* SYM COMPLEN Component is too long.
@@ -459,7 +461,7 @@ H5G_basename (const char *name, size_t *size_p)
*/
static H5G_entry_t *
H5G_namei (H5F_t *f, H5G_entry_t *cwg, const char *name,
- const char **rest, H5G_entry_t *grp_ent)
+ const char **rest/*out*/, H5G_entry_t *grp_ent/*out*/)
{
H5G_entry_t grp; /*entry for current group */
size_t nchars; /*component name length */
@@ -469,7 +471,10 @@ H5G_namei (H5F_t *f, H5G_entry_t *cwg, const char *name,
/* clear output args before FUNC_ENTER() in case it fails */
if (rest) *rest = name;
- if (grp_ent) memset (grp_ent, 0, sizeof(H5G_entry_t));
+ if (grp_ent) {
+ memset (grp_ent, 0, sizeof(H5G_entry_t));
+ H5F_addr_undef (&(grp_ent->header));
+ }
FUNC_ENTER (H5G_namei, NULL, NULL);
@@ -481,7 +486,7 @@ H5G_namei (H5F_t *f, H5G_entry_t *cwg, const char *name,
/* starting point */
if ('/'==*name) {
- if (f->shared->root_sym->header<=0) {
+ if (!H5F_addr_defined (&(f->shared->root_sym->header))) {
/* No root group */
HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, NULL);
}
@@ -528,8 +533,11 @@ H5G_namei (H5F_t *f, H5G_entry_t *cwg, const char *name,
* the name `foo'.
*/
H5O_name_t mesg={0};
- if (!aside && grp.header==f->shared->root_sym->header &&
- H5O_read (f, grp.header, &grp, H5O_NAME, 0, &mesg) &&
+ if (!aside &&
+ H5F_addr_defined (&(grp.header)) &&
+ H5F_addr_defined (&(f->shared->root_sym->header)) &&
+ H5F_addr_eq (&(grp.header), &(f->shared->root_sym->header)) &&
+ H5O_read (f, &(grp.header), &grp, H5O_NAME, 0, &mesg) &&
!HDstrcmp (mesg.s, comp)) {
H5O_reset (H5O_NAME, &mesg);
ret_value = f->shared->root_sym;
@@ -549,15 +557,16 @@ H5G_namei (H5F_t *f, H5G_entry_t *cwg, const char *name,
/* output parameters */
if (rest) *rest = name; /*final null*/
if (grp_ent) {
- if (ret_value->header == f->shared->root_sym->header) {
+ if (H5F_addr_eq (&(ret_value->header), &(f->shared->root_sym->header))) {
HDmemset (grp_ent, 0, sizeof(H5G_entry_t)); /*root has no parent*/
+ H5F_addr_undef (&(grp_ent->header));
} else {
*grp_ent = grp;
}
}
/* Perhaps the root object doesn't even exist! */
- if (ret_value->header<=0) {
+ if (!H5F_addr_defined (&(ret_value->header))) {
HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, NULL); /*root not found*/
}
@@ -627,7 +636,7 @@ H5G_mkroot (H5F_t *f, size_t size_hint)
* re-inserted back into the group directed graph. We might leak file
* memory, but at least we don't loose the original root object.
*/
- if (f->shared->root_sym->header>0) {
+ if (H5F_addr_defined (&(f->shared->root_sym->header))) {
if (H5O_read (f, NO_ADDR, f->shared->root_sym, H5O_STAB, 0, &stab)) {
/* root group already exists */
HGOTO_ERROR (H5E_SYM, H5E_EXISTS, -2);
@@ -1093,10 +1102,10 @@ H5G_create (H5F_t *f, const char *name, size_t ohdr_hint)
* doesn't have a name or we shouldn't interfere with the name
* it already has as a message.
*/
- if (f->shared->root_sym->header>0) {
+ if (H5F_addr_defined (&(f->shared->root_sym->header))) {
HRETURN_ERROR (H5E_SYM, H5E_EXISTS, NULL); /*root exists*/
}
- if ((ent.header = H5O_new (f, 0, ohdr_hint))<0) {
+ if (H5O_new (f, 0, ohdr_hint, &(ent.header)/*out*/)<0) {
/* can't create header */
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, NULL);
}
@@ -1104,7 +1113,7 @@ H5G_create (H5F_t *f, const char *name, size_t ohdr_hint)
HRETURN_ERROR (H5E_SYM, H5E_LINK, NULL); /*bad link count*/
}
*(f->shared->root_sym) = ent;
- if (NULL==(ret_value=H5G_shadow_open (f, &grp, f->shared->root_sym))) {
+ if (NULL==(ret_value=H5G_shadow_open (f, NULL, f->shared->root_sym))) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, NULL);
}
HRETURN (ret_value);
@@ -1132,12 +1141,12 @@ H5G_create (H5F_t *f, const char *name, size_t ohdr_hint)
/*
* Create the object header.
*/
- if ((ent.header = H5O_new (f, 0, ohdr_hint))<0) {
+ if (H5O_new (f, 0, ohdr_hint, &(ent.header)/*out*/)<0) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, NULL);
}
- if (f->shared->root_sym->header<=0) {
+ if (!H5F_addr_defined (&(f->shared->root_sym->header))) {
/*
* This will be the only object in the file. Insert it as the root
* object and add a name messaage to the object header (or modify
@@ -1163,7 +1172,8 @@ H5G_create (H5F_t *f, const char *name, size_t ohdr_hint)
* Make sure the root group exists. Ignore the failure if it's
* because the group already exists.
*/
- hbool_t update_grp = (grp.header==f->shared->root_sym->header);
+ hbool_t update_grp = H5F_addr_eq (&(grp.header),
+ &(f->shared->root_sym->header));
herr_t status = H5G_mkroot (f, H5G_SIZE_HINT);
if (status<0 && -2!=status) {
/* Can't create root group */
@@ -1240,7 +1250,7 @@ H5G_open (H5F_t *f, const char *name)
cwg = H5G_getcwg (f);
assert (cwg || '/'==*name);
- if (f->shared->root_sym->header<=0) {
+ if (!H5F_addr_defined (&(f->shared->root_sym->header))) {
HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, NULL); /*object not found*/
}
if (NULL==(ent=H5G_namei (f, cwg, name, NULL, &grp))) {
@@ -1329,7 +1339,8 @@ H5G_close (H5F_t *f, H5G_entry_t *ent)
*-------------------------------------------------------------------------
*/
herr_t
-H5G_find (H5F_t *f, const char *name, H5G_entry_t *grp_ent, H5G_entry_t *ent)
+H5G_find (H5F_t *f, const char *name,
+ H5G_entry_t *grp_ent/*out*/, H5G_entry_t *ent/*out*/)
{
H5G_entry_t *ent_p = NULL;
H5G_entry_t *cwg = NULL;
@@ -1342,7 +1353,7 @@ H5G_find (H5F_t *f, const char *name, H5G_entry_t *grp_ent, H5G_entry_t *ent)
cwg = H5G_getcwg (f);
assert (cwg || '/'==*name);
- if (f->shared->root_sym->header<=0) {
+ if (!H5F_addr_defined (&(f->shared->root_sym->header))) {
HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL); /*object not found*/
}