From 27078082978818bb1e284677639c1ebac45bf90a Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Thu, 28 Aug 1997 11:37:58 -0500 Subject: [svn-r44] ./src/H5D.c I commented out a bunch of code in H5D_flush() so I could compile and link the test cases. If you commit your changes to that file, whatever they may be, I'll change H5D_flush() to use the new directory functions described below... ./src/H5G.c H5G_namei() ----------- Understands files without directories. The root object (directory or not) can be found by asking for `/' (or any equivalent absolute or relative name like `/.//.///' or `.//.///' (if the cwd is the root)) or by name like `/foo' (or any other equivalent absolute or relative name) if the object has a name message with the value `foo'. This function is used by most of the other H5G functions so they now understand directory-less files too. H5G_new() --------- Creates the root directory implicitly if it doesn't already exist, moving any previous non-directory root object into the new root directory before creating the requested directory within the root. The creation of the root directory happens first, regardless of whether the requested directory creation succeeds. Once the root directory is created it never disappears even if the file later has only one object. This "feature" can be used to force a file to have a root directory by saying something like: H5G_new (..., "/", ...); H5ECLEAR; /*we don't care about the H5E_EXISTS failure*/ The H5G_new() in the previous example fails because the root directory is created implicitly before we attempt to create the requested "/" directory. H5G_find() ---------- Understands files without directories. If there is no root object then this function is guaranteed to fail even if the request is for `/'. As mentioned for H5G_namei(), the root object can be retrieved with `/' or `/foo' (or equivalent absolute or relative names). H5G_insert() ------------ Understands files without directories and attempts to create such files when there is only one object. The root symbol table is created implicitly when necessary. A root object can be given a name message by the caller and then inserted with the name `/' or it can be inserted with the name `/foo' in which case H5G_insert() will set the name message to `foo'. H5G_modify() ------------ Understands files without directories. ./src/H5Fprivate.h Removed the root_type field from hdf5_file_t. ./src/H5Fprivate.h ./src/H5F.c Removed H5F_root_type() ./src/H5Fpublic.h Removed H5F_root_symtype_t. ./src/H5Oprivate.h ./src/H5O.c Added H5O_remove() which is currently a no-op. --- src/H5B.c | 98 +++++++++---------- src/H5C.c | 7 +- src/H5D.c | 3 + src/H5F.c | 58 ------------ src/H5Fprivate.h | 2 - src/H5Fpublic.h | 9 -- src/H5G.c | 279 +++++++++++++++++++++++++++++++++---------------------- src/H5Gnode.c | 8 +- src/H5Gprivate.h | 2 +- src/H5H.c | 8 +- src/H5MM.c | 6 +- src/H5O.c | 33 +++++++ src/H5Oprivate.h | 57 ++++++------ 13 files changed, 299 insertions(+), 271 deletions(-) diff --git a/src/H5B.c b/src/H5B.c index b09e3bc..f1fd996 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -347,7 +347,7 @@ H5B_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5B_t *bt) if (bt->dirty) { /* magic number */ - memcpy (p, H5B_MAGIC, H5B_SIZEOF_MAGIC); + HDmemcpy (p, H5B_MAGIC, H5B_SIZEOF_MAGIC); p += 4; /* node type and level */ @@ -586,12 +586,12 @@ H5B_split (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, intn anchor) /* * Copy data into the new node from the old node. */ - memcpy (bt->page + H5B_SIZEOF_HDR(f), - old->page + H5B_SIZEOF_HDR(f) + delta*recsize, - H5B_K(f,type) * recsize + bt->sizeof_rkey); - memcpy (bt->native, - old->native + delta * type->sizeof_nkey, - (H5B_K(f,type)+1) * type->sizeof_nkey); + HDmemcpy (bt->page + H5B_SIZEOF_HDR(f), + old->page + H5B_SIZEOF_HDR(f) + delta*recsize, + H5B_K(f,type) * recsize + bt->sizeof_rkey); + HDmemcpy (bt->native, + old->native + delta * type->sizeof_nkey, + (H5B_K(f,type)+1) * type->sizeof_nkey); for (i=0, offset=H5B_SIZEOF_HDR(f); i<=2*H5B_K(f,type); @@ -630,12 +630,12 @@ H5B_split (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, intn anchor) old->nchildren = H5B_K(f,type); if (H5B_ANCHOR_RT==anchor) { - memcpy (old->page + H5B_SIZEOF_HDR(f), - old->page + H5B_SIZEOF_HDR(f) + delta*recsize, - H5B_K(f,type) * recsize); - memmove (old->native, - old->native + delta * type->sizeof_nkey, - (H5B_K(f,type)+1) * type->sizeof_nkey); + HDmemcpy (old->page + H5B_SIZEOF_HDR(f), + old->page + H5B_SIZEOF_HDR(f) + delta*recsize, + H5B_K(f,type) * recsize); + HDmemmove (old->native, + old->native + delta * type->sizeof_nkey, + (H5B_K(f,type)+1) * type->sizeof_nkey); for (i=0; i<=2*H5B_K(f,type); i++) { @@ -798,7 +798,7 @@ H5B_insert (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, void *udata) if (!bt->key[0].nkey && H5B_decode_key (f, bt, 0)<0) { HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL); } - memcpy (lt_key, bt->key[0].nkey, type->sizeof_nkey); + HDmemcpy (lt_key, bt->key[0].nkey, type->sizeof_nkey); } /* the new node */ @@ -810,7 +810,7 @@ H5B_insert (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, void *udata) H5B_decode_key (f, bt, bt->nchildren)<0) { HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL); } - memcpy (rt_key, bt->key[bt->nchildren].nkey, type->sizeof_nkey); + HDmemcpy (rt_key, bt->key[bt->nchildren].nkey, type->sizeof_nkey); } /* @@ -872,16 +872,16 @@ H5B_insert (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, void *udata) bt->child[0] = addr; bt->key[0].dirty = 1; bt->key[0].nkey = bt->native; - memcpy (bt->key[0].nkey, lt_key, type->sizeof_nkey); + HDmemcpy (bt->key[0].nkey, lt_key, type->sizeof_nkey); bt->child[1] = child; bt->key[1].dirty = 1; bt->key[1].nkey = bt->native + type->sizeof_nkey; - memcpy (bt->key[1].nkey, md_key, type->sizeof_nkey); + HDmemcpy (bt->key[1].nkey, md_key, type->sizeof_nkey); bt->key[2].dirty = 1; bt->key[2].nkey = bt->native + 2 * type->sizeof_nkey; - memcpy (bt->key[2].nkey, rt_key, type->sizeof_nkey); + HDmemcpy (bt->key[2].nkey, rt_key, type->sizeof_nkey); FUNC_LEAVE (new_root); } @@ -925,13 +925,13 @@ H5B_insert_child (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, /* * The MD_KEY is the left key of the new node. */ - memmove (bt->page + H5B_SIZEOF_HDR(f) + (idx+1)*recsize, - bt->page + H5B_SIZEOF_HDR(f) + idx*recsize, - (bt->nchildren-idx)*recsize + bt->sizeof_rkey); + HDmemmove (bt->page + H5B_SIZEOF_HDR(f) + (idx+1)*recsize, + bt->page + H5B_SIZEOF_HDR(f) + idx*recsize, + (bt->nchildren-idx)*recsize + bt->sizeof_rkey); - memmove (bt->native + (idx+1) * type->sizeof_nkey, - bt->native + idx * type->sizeof_nkey, - ((bt->nchildren-idx)+1) * type->sizeof_nkey); + HDmemmove (bt->native + (idx+1) * type->sizeof_nkey, + bt->native + idx * type->sizeof_nkey, + ((bt->nchildren-idx)+1) * type->sizeof_nkey); for (i=bt->nchildren; i>=idx; --i) { bt->key[i+1].dirty = bt->key[i].dirty; @@ -943,21 +943,21 @@ H5B_insert_child (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, } bt->key[idx].dirty = 1; bt->key[idx].nkey = bt->native + idx * type->sizeof_nkey; - memcpy (bt->key[idx].nkey, md_key, type->sizeof_nkey); + HDmemcpy (bt->key[idx].nkey, md_key, type->sizeof_nkey); } else { /* * The MD_KEY is the right key of the new node. */ - memmove (bt->page + (H5B_SIZEOF_HDR(f) + - (idx+1)*recsize + bt->sizeof_rkey), - bt->page + (H5B_SIZEOF_HDR(f) + - idx*recsize + bt->sizeof_rkey), - (bt->nchildren-idx) * recsize); + HDmemmove (bt->page + (H5B_SIZEOF_HDR(f) + + (idx+1)*recsize + bt->sizeof_rkey), + bt->page + (H5B_SIZEOF_HDR(f) + + idx*recsize + bt->sizeof_rkey), + (bt->nchildren-idx) * recsize); - memmove (bt->native + idx + 2, - bt->native + idx + 1, - (bt->nchildren-idx) * type->sizeof_nkey); + HDmemmove (bt->native + idx + 2, + bt->native + idx + 1, + (bt->nchildren-idx) * type->sizeof_nkey); for (i=bt->nchildren; i>idx; --i) { bt->key[i+1].dirty = bt->key[i].dirty; @@ -969,12 +969,12 @@ H5B_insert_child (hdf5_file_t *f, const H5B_class_t *type, haddr_t addr, } bt->key[idx+1].dirty = 1; bt->key[idx+1].nkey = bt->native + (idx+1) * type->sizeof_nkey; - memcpy (bt->key[idx+1].nkey, md_key, type->sizeof_nkey); + HDmemcpy (bt->key[idx+1].nkey, md_key, type->sizeof_nkey); } - memmove (bt->child + idx + 1, - bt->child + idx, - (bt->nchildren - idx) * sizeof(haddr_t)); + HDmemmove (bt->child + idx + 1, + bt->child + idx, + (bt->nchildren - idx) * sizeof(haddr_t)); bt->child[idx] = child; bt->nchildren += 1; @@ -1064,13 +1064,13 @@ H5B_insert_helper (hdf5_file_t *f, haddr_t addr, const H5B_class_t *type, if (!bt->key[idx].nkey && H5B_decode_key (f, bt, idx)<0) { HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL); } - memcpy (lt_key, bt->key[idx].nkey, type->sizeof_nkey); + HDmemcpy (lt_key, bt->key[idx].nkey, type->sizeof_nkey); /* right key */ if (!bt->key[idx+1].nkey && H5B_decode_key (f, bt, idx+1)<0) { HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL); } - memcpy (rt_key, bt->key[idx+1].nkey, type->sizeof_nkey); + HDmemcpy (rt_key, bt->key[idx+1].nkey, type->sizeof_nkey); /* compare */ if ((cmp=(type->cmp)(f, lt_key, udata, rt_key))<0) { @@ -1096,11 +1096,11 @@ H5B_insert_helper (hdf5_file_t *f, haddr_t addr, const H5B_class_t *type, if (!bt->key[idx].nkey && H5B_decode_key (f, bt, idx)<0) { HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL); } - memcpy (lt_key, bt->key[idx].nkey, type->sizeof_nkey); + HDmemcpy (lt_key, bt->key[idx].nkey, type->sizeof_nkey); if (!bt->key[idx+1].nkey && H5B_decode_key (f, bt, idx+1)<0) { HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL); } - memcpy (rt_key, bt->key[idx+1].nkey, type->sizeof_nkey); + HDmemcpy (rt_key, bt->key[idx+1].nkey, type->sizeof_nkey); } } else if (cmp>0 && idx+1>=bt->nchildren) { idx = bt->nchildren-1; @@ -1109,11 +1109,11 @@ H5B_insert_helper (hdf5_file_t *f, haddr_t addr, const H5B_class_t *type, if (!bt->key[idx].nkey && H5B_decode_key (f, bt, idx)<0) { HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL); } - memcpy (lt_key, bt->key[idx].nkey, type->sizeof_nkey); + HDmemcpy (lt_key, bt->key[idx].nkey, type->sizeof_nkey); if (!bt->key[idx+1].nkey && H5B_decode_key (f, bt, idx+1)<0) { HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL); } - memcpy (rt_key, bt->key[idx+1].nkey, type->sizeof_nkey); + HDmemcpy (rt_key, bt->key[idx+1].nkey, type->sizeof_nkey); } } assert (0==cmp); @@ -1138,11 +1138,11 @@ H5B_insert_helper (hdf5_file_t *f, haddr_t addr, const H5B_class_t *type, bt->key[0].dirty = 1; bt->key[0].nkey = bt->native; - memcpy (bt->key[0].nkey, lt_key, type->sizeof_nkey); + HDmemcpy (bt->key[0].nkey, lt_key, type->sizeof_nkey); bt->key[1].dirty = 1; bt->key[1].nkey = bt->native + type->sizeof_nkey; - memcpy (bt->key[1].nkey, rt_key, type->sizeof_nkey); + HDmemcpy (bt->key[1].nkey, rt_key, type->sizeof_nkey); idx = 0; } @@ -1171,7 +1171,7 @@ H5B_insert_helper (hdf5_file_t *f, haddr_t addr, const H5B_class_t *type, */ if (*lt_key_changed) { bt->key[idx].nkey = bt->native + idx * type->sizeof_nkey; - memcpy (bt->key[idx].nkey, lt_key, type->sizeof_nkey); + HDmemcpy (bt->key[idx].nkey, lt_key, type->sizeof_nkey); bt->dirty += 1; bt->key[idx].dirty = 1; if (idx>0) *lt_key_changed = FALSE; @@ -1179,7 +1179,7 @@ H5B_insert_helper (hdf5_file_t *f, haddr_t addr, const H5B_class_t *type, if (*rt_key_changed) { bt->key[idx+1].nkey = bt->native + (idx+1) * type->sizeof_nkey; - memcpy (bt->key[idx+1].nkey, rt_key, type->sizeof_nkey); + HDmemcpy (bt->key[idx+1].nkey, rt_key, type->sizeof_nkey); bt->dirty += 1; bt->key[idx+1].dirty = 1; if (idx+1nchildren) *rt_key_changed = FALSE; @@ -1229,13 +1229,13 @@ H5B_insert_helper (hdf5_file_t *f, haddr_t addr, const H5B_class_t *type, if (!bt->key[0].nkey && H5B_decode_key (f, bt, 0)<0) { HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL); } - memcpy (md_key, bt->key[0].nkey, type->sizeof_nkey); + HDmemcpy (md_key, bt->key[0].nkey, type->sizeof_nkey); } else { if (!bt->key[bt->nchildren].nkey && H5B_decode_key (f, bt, bt->nchildren)<0) { HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL); } - memcpy (md_key, bt->key[bt->nchildren].nkey, type->sizeof_nkey); + HDmemcpy (md_key, bt->key[bt->nchildren].nkey, type->sizeof_nkey); } } diff --git a/src/H5C.c b/src/H5C.c index 0c84557..d80acde 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -396,6 +396,9 @@ done: Robb Matzke, 13 Aug 1997 Removed H5_BTREE_SIZE and replaced it with H5_SYM_LEAF_K and H5_SYM_INTERN_K. + + Robb Matzke, 26 Aug 1997 + Changed `hash_size' to `val' in two places. --------------------------------------------------------------------------*/ herr_t H5Csetparm(hatom_t tid, file_create_param_t parm, const VOIDP buf) { @@ -434,14 +437,14 @@ herr_t H5Csetparm(hatom_t tid, file_create_param_t parm, const VOIDP buf) case H5_OFFSET_SIZE: val = *(const uintn *)buf; - if(!(val==2 || val==4 || val==8 || val==16 || val==32 || val==64 || val==128 || hash_size==256)) + if(!(val==2 || val==4 || val==8 || val==16 || val==32 || val==64 || val==128 || val==256)) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); template->offset_size=val; break; case H5_LENGTH_SIZE: val = *(const uintn *)buf; - if(!(val==2 || val==4 || val==8 || val==16 || val==32 || val==64 || val==128 || hash_size==256)) + if(!(val==2 || val==4 || val==8 || val==16 || val==32 || val==64 || val==128 || val==256)) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); template->length_size=val; break; diff --git a/src/H5D.c b/src/H5D.c index 05316a3..54b3e5f 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -36,6 +36,7 @@ static char RcsId[] = "@(#)$Revision$"; #include /* Atoms */ #include /* Dataset functions */ #include /* Error handling */ +#include /* Meta data */ #define PABLO_MASK H5D_mask @@ -269,6 +270,7 @@ herr_t H5D_flush(hatom_t oid) /* Check if we have information to flush to the file... */ if(dataset->modified==BTRUE) { +#if 0 /* Check if we need to create the dataset header and insert the dataset in the file's hierarchy */ if(dataset->header==0) { @@ -333,6 +335,7 @@ herr_t H5D_flush(hatom_t oid) /* Add the appropriate messages for the dataset */ } /* end if */ +#endif } /* end if */ done: diff --git a/src/H5F.c b/src/H5F.c index bed46fd..3d8b570 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -336,7 +336,6 @@ H5F_new (void) /* Create a root symbol slot */ f->root_sym = H5MM_xcalloc (1, sizeof (H5G_entry_t)); f->root_sym->type = H5G_NOTHING_CACHED; - f->root_type=H5F_ROOT_NONE; return f; } @@ -792,63 +791,6 @@ done: FUNC_LEAVE(ret_value); } /* end H5Fclose() */ -/*-------------------------------------------------------------------------- - NAME - H5F_root_type - PURPOSE - Check the type of the root symbol-entry for a file. - USAGE - H5F_root_symtype_t_ H5F_root_type(fid) - int32 fid; IN: File ID of file to query - RETURNS - Returns root symbol type on success, H5F_ROOT_ERROR on failure. - DESCRIPTION - This function retrieves the type of symbol-entry the root object in the - file describes. Legimate values are: - H5F_ROOT_NONE - Root-symbol table is empty, neither a dataset nor a directory is the root object - H5F_ROOT_UNKNOWN - Don't know (yet) if the root object is a dataset or a directory - H5F_ROOT_DATASET - Root object is a dataset - H5F_ROOT_DIRECTORY - Root object is a directory - - This function is designed for internal use and should be modified to - not return H5F_ROOT_UNKNOWN if it is made part of the public API. - - ERRORS - H5E_ARGS - H5E_BADTYPE - Argument checking - H5E_ATOM - H5E_BADATOM - Can't get the object for an atom - MODIFICATIONS: - Quincey Koziol, 13 Aug 1997 ---------------------------------------------------------------------------*/ -H5F_root_symtype_t H5F_root_type(hatom_t fid) -{ - hdf5_file_t *f=NULL; /* file struct for new file */ - H5F_root_symtype_t ret_value = H5F_ROOT_ERROR; - - FUNC_ENTER(H5F_root_type, H5F_init_interface, H5F_ROOT_ERROR); - - /* Clear errors and check args and all the boring stuff. */ - H5ECLEAR; - if(H5Aatom_group(fid)!=H5_FILE) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL); - - /* Get the file handle to close */ - if((f=H5Aatom_object(fid))==NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); - - ret_value=f->root_type; - -done: - if(ret_value == H5F_ROOT_ERROR) - { /* Error condition cleanup */ - - } - - /* Normal function cleanup */ - - FUNC_LEAVE(ret_value); -} /* end H5F_root_type() */ - - /*------------------------------------------------------------------------- * Function: H5F_block_read diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index e53c233..e517670 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -304,7 +304,6 @@ typedef struct { file_access_temp_t file_access_parms; /* File-access template */ #endif struct H5G_entry_t *root_sym; /* Root symbol table entry */ - H5F_root_symtype_t root_type; /* What kind of symbol is the root? */ } hdf5_file_t; @@ -357,7 +356,6 @@ typedef struct { void H5F_encode_length_unusual(const hdf5_file_t *f, uint8 **p, uint8 *l); void H5F_encode_offset_unusual(const hdf5_file_t *f, uint8 **p, uint8 *o); intn H5F_compare_filename(const VOIDP obj, const VOIDP key); -H5F_root_symtype_t H5F_root_type(hatom_t fid); herr_t H5F_block_read (hdf5_file_t *f, haddr_t addr, size_t size, void *buf); herr_t H5F_block_write (hdf5_file_t *f, haddr_t addr, size_t size, void *buf); herr_t H5F_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index fab328d..b5e3350 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -27,15 +27,6 @@ #define H5ACC_WRITE 0x0001 /* Use in H5Fopen to open a file with write access */ #define H5ACC_OVERWRITE 0x0002 /* Use in H5Fcreate truncate an existing file */ -/* Type of root rymbol-table entry */ -typedef enum { - H5F_ROOT_NONE=0, /* Root-symbol table is empty, neither a dataset nor a directory is the root object */ - H5F_ROOT_UNKNOWN, /* Don't know if the root object is a dataset or a directory */ - H5F_ROOT_DATASET, /* Root object is a dataset */ - H5F_ROOT_DIRECTORY, /* Root object is a directory */ - H5F_ROOT_ERROR /* Error value */ - } H5F_root_symtype_t; - #ifdef __cplusplus extern "C" { #endif diff --git a/src/H5G.c b/src/H5G.c index bea4a9a..344ea48 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -40,6 +40,7 @@ #define H5G_INIT_HEAP 8192 #define PABLO_MASK H5G_mask +static herr_t H5G_mkroot (hdf5_file_t *f, size_t size_hint); /* Is the interface initialized? */ static intn interface_initialize_g = FALSE; @@ -105,7 +106,7 @@ H5G_basename (const char *name, size_t *size_p) assert (name); - s = name + strlen(name); + s = name + HDstrlen(name); while (s>name && '/'==s[-1]) --s; /*skip past trailing slashes*/ while (s>name && '/'!=s[-1]) --s; /*skip past base name*/ @@ -115,7 +116,7 @@ H5G_basename (const char *name, size_t *size_p) */ if ('/'==*s) { if (size_p) *size_p = 0; - return s + strlen(s); /*null terminator*/ + return s + HDstrlen(s); /*null terminator*/ } if (size_p) *size_p = strcspn (s, "/"); @@ -126,7 +127,9 @@ H5G_basename (const char *name, size_t *size_p) /*------------------------------------------------------------------------- * Function: H5G_namei * - * Purpose: Given a name (absolute or relative) return the symbol table + * Purpose: (Partially) translates a name to a symbol table entry. + * + * Given a name (absolute or relative) return the symbol table * entry for that name and for the directory that contains the * base name. These entries (DIR_ENT and BASE_ENT) are returned * through memory passed into the function by the caller. Either @@ -141,12 +144,6 @@ H5G_basename (const char *name, size_t *size_p) * `..' is not internally recognized (it is recognized if * such a name appears in the symbol table). * - * As a special case, if the NAME is the string `/' (or - * equivalent) then DIR_ENT and BASE_ENT are both initialized - * to the contents of the root symbol table entry. However, - * the contents of the root symbol table entry may be - * uninitialized. - * * If the name cannot be fully resolved, then REST will * point to the part of NAME where the traversal failed * (REST will always point to a relative name) and BASE_ENT @@ -155,6 +152,18 @@ H5G_basename (const char *name, size_t *size_p) * the traversal failed. However, if the name can be fully * resolved, then REST points to the null terminator of NAME. * + * As a special case, if the NAME is the name `/' (or + * equivalent) then DIR_ENT is initialized to all zero and + * BASE_ENT is initialized with the contents of the root + * symbol table entry. + * + * As a special case, if the NAME is the string `/foo' (or + * equivalent) and the root symbol table entry points to a + * non-directory object with a name message with the value + * `foo' then DIR_ENT is initialized to all zero and BASE_ENT + * is initialized with the contents of the root symbol table + * entry. + * * Return: Success: SUCCEED if the name can be fully * resolved. * @@ -180,6 +189,7 @@ H5G_namei (hdf5_file_t *f, H5G_entry_t *cwd, const char *name, H5G_entry_t *tmp, *dir, *base; /*ptrs to DIR and BASE entries */ size_t nchars; /*component name length */ char comp[1024]; /*component name buffer */ + hbool_t aside = FALSE; /*did we look at a name message?*/ FUNC_ENTER (H5G_namei, NULL, FAIL); @@ -224,10 +234,25 @@ H5G_namei (hdf5_file_t *f, H5G_entry_t *cwd, const char *name, HDmemcpy (comp, name, nchars); comp[nchars] = '\0'; - /* - * Look for the component in the current symbol table. - */ if (H5G_stab_find (f, dir, comp, base)<0) { + /* + * Component was not found in the current symbol table, probably + * because it isn't a symbol table. If it is the root symbol then + * see if it has the appropriate name field. The ASIDE variable + * prevents us from saying `/foo/foo' where the root object has + * the name `foo'. + */ + H5O_name_t mesg; + if (!aside && dir->header==f->root_sym->header && + H5O_read (f, dir->header, dir, H5O_NAME, 0, &mesg)) { + if (!strcmp (mesg.s, comp)) { + H5O_reset (H5O_NAME, &mesg); + *base = *dir; + aside = TRUE; + } + H5O_reset (H5O_NAME, &mesg); + } + /* component not found */ if (dir_ent) *dir_ent = *dir; HRETURN_ERROR (H5E_DIRECTORY, H5E_NOTFOUND, -2); @@ -236,11 +261,22 @@ H5G_namei (hdf5_file_t *f, H5G_entry_t *cwd, const char *name, /* next component */ name += nchars; } - + /* output parameters */ if (rest) *rest = name; /*final null*/ - if (dir_ent) *dir_ent = *dir; + if (dir_ent) { + if (base->header == f->root_sym->header) { + HDmemset (dir_ent, 0, sizeof(H5G_entry_t)); /*root has no parent*/ + } else { + *dir_ent = *dir; + } + } if (base_ent) *base_ent = *base; + + /* Perhaps the root object doesn't even exist! */ + if (base->header<=0) { + HRETURN_ERROR (H5E_DIRECTORY, H5E_NOTFOUND, -2); /*root not found*/ + } FUNC_LEAVE (SUCCEED); } @@ -250,11 +286,11 @@ H5G_namei (hdf5_file_t *f, H5G_entry_t *cwd, const char *name, * Function: H5G_mkroot * * Purpose: Creates the root directory if it doesn't exist; otherwise - * nothing happens. If the root symbol table previously - * pointed to something other than a directory, then that - * object is made a member of the root directory and is - * given a name corresponding to the object name message. - * If the root object doesn't have an object name message + * nothing happens. If the root symbol table entry previously + * pointed to something other than a directory, then that object + * is made a member of the root directory and is given a name + * corresponding to the object's name message (the name message + * is removed). If the root object doesn't have a name message * then the name `Root Object' is used. * * Return: Success: SUCCEED @@ -267,9 +303,8 @@ H5G_namei (hdf5_file_t *f, H5G_entry_t *cwd, const char *name, * * Modifications: * - *------------------------------------------------------------------------- - */ -herr_t + *------------------------------------------------------------------------- */ +static herr_t H5G_mkroot (hdf5_file_t *f, size_t size_hint) { H5O_stab_t stab; /*symbol table message */ @@ -277,14 +312,15 @@ H5G_mkroot (hdf5_file_t *f, size_t size_hint) H5G_entry_t root; /*old root entry */ const char *root_name=NULL; /*name of old root object */ intn nlinks; /*number of links */ + hbool_t reset = FALSE; /*should name message be reset? */ FUNC_ENTER (H5G_mkroot, NULL, FAIL); /* * Is there already a root object that needs to move into the new - * root symbol table? + * root symbol table? The root object is a symbol table if we can + * read the H5O_STAB message. */ - name.s = NULL; if (f->root_sym->header>0) { if (H5O_read (f, f->root_sym->header, f->root_sym, H5O_STAB, 0, &stab)) { /* root directory already exists */ @@ -293,6 +329,8 @@ H5G_mkroot (hdf5_file_t *f, size_t size_hint) 0, &name)) { root = *(f->root_sym); root_name = name.s; /*dont reset name until root_name is done*/ + reset = TRUE; + H5O_remove (f, f->root_sym->header, f->root_sym, H5O_NAME, H5O_ALL); } else { root = *(f->root_sym); root_name = "Root Object"; @@ -318,17 +356,19 @@ H5G_mkroot (hdf5_file_t *f, size_t size_hint) * of 1. */ if (root_name) { + +#ifndef NDEBUG nlinks = H5O_link (f, root.header, &root, 0); assert (1==nlinks); +#endif if (H5G_stab_insert (f, f->root_sym, root_name, &root)) { /* can't insert old root object in new root directory */ H5O_reset (H5O_NAME, &name); HRETURN_ERROR (H5E_DIRECTORY, H5E_CANTINIT, FAIL); } - H5O_reset (H5O_NAME, &name); + if (reset) H5O_reset (H5O_NAME, &name); } - f->root_type=H5F_ROOT_DIRECTORY; /* set the root symbol type be a directory */ FUNC_LEAVE (SUCCEED); } @@ -344,9 +384,10 @@ H5G_mkroot (hdf5_file_t *f, size_t size_hint) * table entry for the new directory's parent and ENT will * contain the symbol table entry for the new directory. * - * Do not use this function to create the root symbol table - * since it is a special case. Use H5G_mkroot() instead. - * Creating `/' with this function will return failure. + * A root directory is created implicitly by this function + * when necessary. Calling this function with the name "/" + * (or any equivalent name) will result in an H5E_EXISTS + * failure. * * Return: Success: SUCCEED, if DIR_ENT is not the null pointer * then it will be initialized with the @@ -382,6 +423,10 @@ H5G_new (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, if (!dir_ent) dir_ent = &_parent; if (!ent) ent = &_child; + /* Create root directory if necessary */ + H5G_mkroot (f, size_hint); + H5ECLEAR; + /* lookup name */ status = H5G_namei (f, cwd, name, &rest, dir_ent, NULL); if (status<0 && !rest) { @@ -403,7 +448,7 @@ H5G_new (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, HRETURN_ERROR (H5E_DIRECTORY, H5E_COMPLEN, FAIL); } else { /* null terminate */ - memcpy (_comp, rest, nchars); + HDmemcpy (_comp, rest, nchars); _comp[nchars] = '\0'; rest = _comp; } @@ -426,16 +471,19 @@ H5G_new (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, /*------------------------------------------------------------------------- * Function: H5G_find * - * Purpose: Finds an object with the specified NAME in file F. If the - * name is relative then it is interpretted relative to CWD, - * a symbol table entry for a symbol table. On successful return, - * DIR_ENT (if non-null) will be initialized with the symbol table - * information for the directory in which the object appears - * and ENT will be initialized with the symbol table entry for - * the object. + * Purpose: Finds an object with the specified NAME in file F. If + * the name is relative then it is interpretted relative + * to CWD, a symbol table entry for a symbol table. On + * successful return, DIR_ENT (if non-null) will be + * initialized with the symbol table information for the + * directory in which the object appears (or all zero if + * the returned object is the root object) and ENT will + * be initialized with the symbol table entry for the + * object (ENT is optional when the caller is interested + * only in the existence of the object). * - * ENT is optional when the caller is interested only in the - * existence of the object. + * This function will fail if the root object is + * requested and there is none. * * Return: Success: SUCCEED with DIR_ENT and ENT initialized. * @@ -447,8 +495,7 @@ H5G_new (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, * * Modifications: * - *------------------------------------------------------------------------- - */ + *------------------------------------------------------------------------- */ herr_t H5G_find (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, const char *name, H5G_entry_t *ent) @@ -460,6 +507,10 @@ H5G_find (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, assert (name && *name); assert (cwd || '/'==*name); + if (f->root_sym->header<=0) { + HRETURN_ERROR (H5E_DIRECTORY, H5E_NOTFOUND, FAIL); /*object not found*/ + } + if (H5G_namei (f, cwd, name, NULL, dir_ent, ent)<0) { HRETURN_ERROR (H5E_DIRECTORY, H5E_NOTFOUND, FAIL); /*object not found*/ } @@ -475,11 +526,12 @@ H5G_find (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, * giving it the specified NAME. If NAME is relative then * it is interpreted with respect to the CWD pointer. If * non-null, DIR_ENT will be initialized with the symbol table - * entry for the directory which contains the new ENT. + * entry for the directory which contains the new ENT (or all + * zero if the new ENT is the root object). * - * NAME must not be the name of the root symbol table entry - * ('/') since that is a special case. If NAME is the root - * symbol table entry, then this function will return failure. + * This function attempts to use a non-directory file if + * the file contains just one object. The one object + * will be the root object. * * Inserting an object entry into the symbol table increments * the link counter for that object. @@ -496,8 +548,7 @@ H5G_find (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, * * Modifications: * - *------------------------------------------------------------------------- - */ + *------------------------------------------------------------------------- */ herr_t H5G_insert (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, const char *name, H5G_entry_t *ent) @@ -507,6 +558,7 @@ H5G_insert (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, H5G_entry_t _parent; size_t nchars; char _comp[1024]; + H5O_stab_t stab; FUNC_ENTER (H5G_insert, NULL, FAIL); @@ -517,7 +569,21 @@ H5G_insert (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, assert (ent); if (!dir_ent) dir_ent = &_parent; - /* lookup name */ + /* + * If there's already an object or if this object is a directory then + * create a root directory. The object is a directory if we can read + * the symbol table message from its header. H5G_mkroot() fails if + * the root object is already a directory, but we don't care. + */ + if (f->root_sym->header>0 || + H5O_read (f, ent->header, ent, H5O_STAB, 0, &stab)) { + H5G_mkroot (f, H5G_SIZE_HINT); + H5ECLEAR; + } + + /* + * Look up the name -- it shouldn't exist yet. + */ status = H5G_namei (f, cwd, name, &rest, dir_ent, NULL); if (status<0 && !rest) { HRETURN_ERROR (H5E_DIRECTORY, H5E_CANTINIT, FAIL); /*lookup failed*/ @@ -526,84 +592,76 @@ H5G_insert (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, } H5ECLEAR; /*it's OK that we didn't find it*/ - /* should be one null-terminated component left */ + /* + * The caller may be attempting to insert a root object that either + * doesn't have a name or we shouldn't interfere with the name + * it already has. + */ rest = H5G_component (rest, &nchars); - assert (rest && *rest); + if (!rest || !*rest) { + if (f->root_sym->header>0) { + HRETURN_ERROR (H5E_DIRECTORY, H5E_EXISTS, FAIL); /*root exists*/ + } + HDmemset (dir_ent, 0, sizeof(H5G_entry_t)); + if (1!=H5O_link (f, ent->header, ent, 1)) { + HRETURN_ERROR (H5E_DIRECTORY, H5E_LINK, FAIL); /*bad link count*/ + } + *(f->root_sym) = *ent; + HRETURN (SUCCEED); + } + + /* + * There should be one component left. Make sure it's null + * terminated. + */ if (rest[nchars]) { if (H5G_component (rest+nchars, NULL)) { - /* missing component */ + /* name component not found */ HRETURN_ERROR (H5E_DIRECTORY, H5E_NOTFOUND, FAIL); } else if (nchars+1 > sizeof _comp) { - /* component name is too long */ + /* name component is too long */ HRETURN_ERROR (H5E_DIRECTORY, H5E_COMPLEN, FAIL); } else { /* null terminate */ - memcpy (_comp, rest, nchars); + HDmemcpy (_comp, rest, nchars); _comp[nchars] = '\0'; rest = _comp; } } + /* + * If this is the only object then insert it as the root object. Add + * a name messaage to the object header (or modify the first one we + * find). + */ + if (f->root_sym->header<=0) { + H5O_name_t name_mesg; + name_mesg.s = rest; + if (H5O_modify (f, ent->header, ent, NULL, H5O_NAME, 0, &name_mesg)<0) { + /* cannot add/change name message */ + HRETURN_ERROR (H5E_DIRECTORY, H5E_CANTINIT, FAIL); + } + if (1!=H5O_link (f, ent->header, ent, 1)) { + HRETURN_ERROR (H5E_DIRECTORY, H5E_LINK, FAIL); /*bad link count*/ + } + *(f->root_sym) = *ent; + HRETURN (SUCCEED); + } + /* increment the link count */ if (H5O_link (f, ent->header, ent, 1)<0) { - HRETURN_ERROR (H5E_DIRECTORY, H5E_LINK, FAIL); /*can't increase linkage*/ + HRETURN_ERROR (H5E_DIRECTORY, H5E_LINK, FAIL); /*link inc failure*/ } /* insert entry into parent */ if (H5G_stab_insert (f, dir_ent, rest, ent)<0) { + H5O_link (f, ent->header, ent, -1); /*don't care if it fails*/ HRETURN_ERROR (H5E_DIRECTORY, H5E_CANTINIT, FAIL); /*can't insert*/ } FUNC_LEAVE (SUCCEED); } -/*-------------------------------------------------------------------------- - NAME - H5G_set_root - PURPOSE - Inserts symbol table ENT as the file's root object giving it the specified - NAME. NAME is not allowed to be relative. - USAGE - herr_t H5G_set_root(f, name, ent) - hatom_t f; IN: File to set root entry - const char *name; IN: Root object's name - H5G_entry_t *ent; IN: Root object's symbol-table entry - RETURNS - SUCCEED/FAIL - DESCRIPTION - This function sets the root object of a file to be the symbol-table - table passed as an argument. The primary function of this routine is to - make a dataset the root object of a file. (The dataset may be replaced - with a "real" root directory, but at this point, the dataset is the only - object in the file) ---------------------------------------------------------------------------*/ -herr_t -H5G_set_root (hdf5_file_t *f, const char *name, H5G_entry_t *ent) -{ - herr_t status; - const char *rest=NULL; - H5G_entry_t _parent; - size_t nchars; - char _comp[1024]; - - FUNC_ENTER (H5G_set_root, NULL, FAIL); - - /* check args */ - assert (f); - assert (name && *name); - assert (ent); - - /* lookup base-name */ - if(HDstrlen(rest = H5G_basename (name, NULL))<=0) - HRETURN_ERROR (H5E_SYM, H5E_BADVALUE, FAIL); /* invalid base name */ - H5ECLEAR; - - /* insert entry as root object */ - HDmemcpy(file->root_sym,ent,sizeof(H5G_entry_t)); - - FUNC_LEAVE (SUCCEED); -} - /*------------------------------------------------------------------------- * Function: H5G_modify @@ -639,7 +697,6 @@ H5G_modify (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, { const char *rest=NULL; H5G_entry_t _parent; - size_t nchars; FUNC_ENTER (H5G_modify, NULL, FAIL); @@ -655,14 +712,12 @@ H5G_modify (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, HRETURN_ERROR (H5E_DIRECTORY, H5E_NOTFOUND, FAIL); /*entry not found*/ } - /* get the base name */ - rest = H5G_basename (name, &nchars); - - /* cannot modify the root symbol entry */ - if (!*rest) HRETURN_ERROR (H5E_DIRECTORY, H5E_NOTFOUND, FAIL); - - /* modify entry in parent */ - if (H5G_stab_modify (f, dir_ent, rest, ent)<0) { + /* + * Modify the entry in the parent or in the file struct. + */ + if (dir_ent->header<=0) { + *(f->root_sym) = *ent; + } else if (H5G_stab_modify (f, dir_ent, rest, ent)<0) { HRETURN_ERROR (H5E_DIRECTORY, H5E_CANTINIT, FAIL); /*can't modify*/ } @@ -1076,7 +1131,7 @@ H5G_decode (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent) break; default: - abort(); + HDabort(); } *pp = p_ret + H5G_SIZEOF_ENTRY(f); @@ -1187,7 +1242,7 @@ H5G_encode (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent) break; default: - abort(); + HDabort(); } /* fill with zero */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 709753b..797eb5c 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -313,7 +313,7 @@ H5G_node_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5G_node_t *sym) /* entries */ H5G_encode_vec (f, &p, sym->entry, sym->nsyms); - memset (p, 0, size - (p-buf)); + HDmemset (p, 0, size - (p-buf)); status = H5F_block_write (f, addr, size, buf); buf = H5MM_xfree (buf); @@ -665,7 +665,7 @@ H5G_node_insert (hdf5_file_t *f, haddr_t addr, intn *anchor, * heap address changed and update the symbol table object header * with the new heap address. */ - offset = H5H_insert (f, udata->heap, strlen(udata->name)+1, udata->name); + offset = H5H_insert (f, udata->heap, HDstrlen(udata->name)+1, udata->name); udata->entry.name_off = offset; if (offset<0) HGOTO_ERROR (H5E_SYM, H5E_CANTINSERT, FAIL); @@ -685,8 +685,8 @@ H5G_node_insert (hdf5_file_t *f, haddr_t addr, intn *anchor, sn->dirty += 1; if (idx<=H5G_NODE_K(f)) { - memmove (sn->entry+idx+1, sn->entry+idx, - (H5G_NODE_K(f)-idx) * sizeof(H5G_entry_t)); + HDmemmove (sn->entry+idx+1, sn->entry+idx, + (H5G_NODE_K(f)-idx) * sizeof(H5G_entry_t)); sn->entry[idx] = udata->entry; sn->entry[idx].name_off = offset; sn->nsyms += 1; diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 841fbbf..e0794b0 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -26,6 +26,7 @@ #define H5G_NODE_MAGIC "SNOD" /*symbol table node magic number */ #define H5G_NODE_SIZEOF_MAGIC 4 /*sizeof symbol node magic number */ #define H5G_NODE_VERS 1 /*symbol table node version number */ +#define H5G_SIZE_HINT 1024 /*default root dir size hint */ #define H5G_NODE_K(F) ((F)->file_create_parms.sym_leaf_k) #define H5G_NODE_SIZEOF_HDR(F) (H5G_NODE_SIZEOF_MAGIC + 4) #define H5G_SIZEOF_ENTRY(F) \ @@ -134,7 +135,6 @@ extern const H5B_class_t H5B_SNODE[1]; */ /* functions that understand directories */ -herr_t H5G_mkroot (hdf5_file_t *f, size_t size_hint); herr_t H5G_new (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, const char *name, size_t size_hint, H5G_entry_t *ent); herr_t H5G_find (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, diff --git a/src/H5H.c b/src/H5H.c index e4984af..6da97e6 100644 --- a/src/H5H.c +++ b/src/H5H.c @@ -626,7 +626,7 @@ H5H_insert (hdf5_file_t *f, haddr_t addr, size_t buf_size, const void *buf) H5H_SIZEOF_HDR(f)+heap->mem_alloc); /* clear new section so junk doesn't appear in the file */ - memset (heap->chunk+H5H_SIZEOF_HDR(f)+old_size, 0, need_more); + HDmemset (heap->chunk+H5H_SIZEOF_HDR(f)+old_size, 0, need_more); } /* @@ -929,11 +929,11 @@ H5H_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, for (j=0; j<16; j++) { if (i+jdisk_alloc) { if (marker[i+j]) { - fputc (' ', stream); + HDfputc (' ', stream); } else { c = h->chunk[H5H_SIZEOF_HDR(f)+i+j]; - if (c>' ' && c<'~') fputc (c, stream); - else fputc ('.', stream); + if (c>' ' && c<'~') HDfputc (c, stream); + else HDfputc ('.', stream); } } } diff --git a/src/H5MM.c b/src/H5MM.c index f15b306..680d392 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -105,7 +105,7 @@ H5MM_xrealloc (void *mem, size_t size) mem = H5MM_xfree (mem); } else { - mem = realloc (mem, size); + mem = HDrealloc (mem, size); assert (mem); } @@ -138,8 +138,8 @@ H5MM_xstrdup (const char *s) char *mem; if (!s) return NULL; - mem = H5MM_xmalloc (strlen (s)+1); - strcpy (mem, s); + mem = H5MM_xmalloc (HDstrlen (s)+1); + HDstrcpy (mem, s); return mem; } diff --git a/src/H5O.c b/src/H5O.c index 22cb15f..0eb04bc 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -766,6 +766,39 @@ H5O_modify (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, /*------------------------------------------------------------------------- + * Function: H5O_remove + * + * Purpose: Removes the specified message from the object header. + * If sequence is H5O_ALL (-1) then all messages of the + * specified type are removed. Removing a message causes + * the sequence numbers to change for subsequent messages of + * the same type. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * robb@maya.nuance.com + * Aug 28 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_remove (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, + const H5O_class_t *type, intn sequence) +{ + FUNC_ENTER (H5O_remove, NULL, FAIL); + + fprintf (stderr, "H5O_remove: not implemented yet (no-op)!\n"); + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- * Function: H5O_alloc_extend_chunk * * Purpose: Extends a chunk which hasn't been allocated on disk yet diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 34acff9..43aace9 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -28,6 +28,7 @@ #define H5O_NCHUNKS 8 /*initial number of chunks */ #define H5O_NEW_MESG (-1) /*new message */ #define H5O_NO_ADDR (-1) /*no disk address yet */ +#define H5O_ALL (-1) /*delete all messages of type */ #define H5O_VERSION 1 #define H5O_ALIGNMENT 4 @@ -90,13 +91,39 @@ typedef struct H5O_t { extern const H5O_class_t H5O_NULL[1]; /* + * Simple Dimensionality message. + */ +#define H5O_SIM_DIM_ID 0x0001 +extern const H5O_class_t H5O_SIM_DIM[1]; + +typedef struct { + uint32 rank; /* Number of dimensions */ + uint32 dim_flags; /* Dimension flags */ + uint32 *size; /* Dimension sizes */ + uint32 *max; /* Maximum dimension sizes */ + uint32 *perm; /* Dimension permutations */ +} H5O_sim_dim_t; + +/* + * Simple Datatype message. + */ +#define H5O_SIM_DTYPE_ID 0x0003 +extern const H5O_class_t H5O_SIM_DTYPE[1]; + +typedef struct { + uint8 length; /* Number of bytes */ + uint8 arch; /* Architecture format of the data */ + hatom_t type; /* Type of the data */ +} H5O_sim_dtype_t; + +/* * Object name message. */ #define H5O_NAME_ID 0x000d extern const H5O_class_t H5O_NAME[1]; typedef struct H5O_name_t { - char *s; /*ptr to malloc'd memory */ + const char *s; /*ptr to malloc'd memory */ } H5O_name_t; /* @@ -124,32 +151,6 @@ typedef struct H5O_stab_t { haddr_t heap; /*address of name heap */ } H5O_stab_t; -/* - * Simple Datatype message. - */ -#define H5O_SIM_DTYPE_ID 0x0003 -extern const H5O_class_t H5O_SIM_DTYPE[1]; - -typedef struct { - uint8 length; /* Number of bytes */ - uint8 arch; /* Architecture format of the data */ - hatom_t type; /* Type of the data */ -} H5O_sim_dtype_t; - -/* - * Simple Dimensionality message. - */ -#define H5O_SIM_DIM_ID 0x0001 -extern const H5O_class_t H5O_SIM_DIM[1]; - -typedef struct { - uint32 rank; /* Number of dimensions */ - uint32 dim_flags; /* Dimension flags */ - uint32 *size; /* Dimension sizes */ - uint32 *max; /* Maximum dimension sizes */ - uint32 *perm; /* Dimension permutations */ -} H5O_sim_dim_t; - haddr_t H5O_new (hdf5_file_t *f, intn nlink, size_t size_hint); @@ -161,6 +162,8 @@ const void *H5O_peek (hdf5_file_t *f, haddr_t addr, const H5O_class_t *type, intn H5O_modify (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, hbool_t *ent_modified, const H5O_class_t *type, intn overwrite, const void *mesg); +herr_t H5O_remove (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, + const H5O_class_t *type, intn sequence); herr_t H5O_reset (const H5O_class_t *type, void *native); herr_t H5O_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth); -- cgit v0.12