[svn-r328] Changes since 19980318

----------------------
./src/H5B.c
./src/H5Bprivate.h
./src/H5G.c
./src/H5Gnode.c
./src/H5Gpkg.h
./src/H5Gpublic.h
./src/H5Gstab.c
	Implemented H5Giterate().  However, since most functions can't
	take a group ID in place of a file ID yet, there's not a whole
	lot that the operator can do besides print the name or something.

./test/H5O.c
	Fixed writing of four uninitialized bytes to the file as part
	of an object header.

./test/istore.c
	For some reason, `mpirun -np 1 istore' results in extra
	arguments on the command line that istore doesn't understand.
	I'm probably forgetting to call some MPI function in
	main(). Albert, Kim?  So I commented out the `exit(1)' for the
	time being.
This commit is contained in:
Robb Matzke 1998-03-24 09:53:57 -05:00
parent af6558c7cb
commit 2ed9aa69f7
11 changed files with 1117 additions and 1085 deletions

View File

@ -75,14 +75,14 @@
./html/ph5example.c
./html/ph5implement.txt
./html/pipe1.gif
./html/pipe1.gif
./html/pipe2.gif
./html/pipe1.obj
./html/pipe2.gif
./html/pipe2.obj
./html/pipe3.gif
./html/pipe3.obj
./html/pipe4.gif
./html/pipe4.obj
./html/pipe4.obj
./html/pipe5.obj
./html/pipe5.gif
./html/pipe5.obj
./html/heap.txt
./html/index.html

2
configure vendored
View File

@ -1982,7 +1982,7 @@ fi
echo $ac_n "checking for parallel support""... $ac_c" 1>&6
echo "configure:1984: checking for parallel support" >&5;
RUNTEST=""
case "X-$PARALLEL" in

1729
src/H5B.c

File diff suppressed because it is too large Load Diff

View File

@ -38,6 +38,7 @@
(H5B_SIZEOF_MAGIC + /*magic number */ \
4 + /*type, level, num entries */ \
2*H5F_SIZEOF_ADDR(F)) /*left and right sibling addresses */
#define H5B_K(F,TYPE) /*K value given file and Btree subclass */ \
((F)->shared->create_parms.btree_k[(TYPE)->id])
@ -121,6 +122,6 @@ herr_t H5B_find (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
void *udata);
herr_t H5B_insert (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
void *udata);
herr_t H5B_list (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
void *udata);
herr_t H5B_iterate (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
void *udata);
#endif

125
src/H5G.c
View File

@ -48,7 +48,7 @@
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT H5G_init_interface
#define INTERFACE_INIT H5G_init_interface
static herr_t H5G_init_interface(void);
static void H5G_term_interface(void);
@ -364,6 +364,86 @@ H5Gpop(hid_t file_id)
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Giterate
*
* Purpose: Iterates over the entries of a group. The FILE_ID and NAME
* identify the group over which to iterate and INDEX indicates
* where to start iterating (zero means at the beginning). The
* OPERATOR is called for each member and the iteration
* continues until the operator returns non-zero or all members
* are processed. The operator is passed a group ID for the
* group being iterated, a member name, and OP_DATA for each
* member.
*
* Return: Success: The return value of the first operator that
* returns non-zero, or zero if all members were
* processed with no operator returning non-zero.
*
* Failure: FAIL if something goes wrong within the
* library, or a negative value returned by one
* of the operators.
*
* Programmer: Robb Matzke
* Monday, March 23, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Giterate (hid_t file_id, const char *name, int *index,
H5G_iterate_t op, void *op_data)
{
H5F_t *f = NULL;
int _index = 0;
H5G_bt_ud2_t udata;
herr_t ret_value = FAIL;
FUNC_ENTER (H5Giterate, FAIL);
/* Check args */
if (H5_FILE!=H5I_group (file_id) ||
NULL==(f=H5I_object (file_id))) {
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
}
if (!name || !*name) {
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
}
if (!index) index = &_index;
if (!op) {
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified");
}
/*
* Open the group on which to operate. We also create a group ID which
* we can pass to the application-defined operator.
*/
if (NULL==(udata.group = H5G_open (f, name))) {
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to open group");
}
if ((udata.group_id=H5I_register (H5_GROUP, udata.group))<0) {
H5G_close (udata.group);
HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
"unable to register group");
}
/* Build udata to pass through H5B_iterate() to H5G_node_iterate() */
udata.skip = *index;
udata.op = op;
udata.op_data = op_data;
/* Iterate over the group members */
if ((ret_value = H5B_iterate (f, H5B_SNODE,
&(udata.group->ent.cache.stab.btree_addr),
&udata))<0) {
HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed");
}
H5I_dec_ref (udata.group_id); /*also closes udata.group*/
FUNC_LEAVE (ret_value);
}
/*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
@ -523,22 +603,19 @@ H5G_component(const char *name, size_t *size_p)
*/
static herr_t
H5G_namei(H5F_t *f, H5G_entry_t *cwg, const char *name,
const char **rest /*out */ , H5G_entry_t *grp_ent /*out */ ,
H5G_entry_t *obj_ent /*out */ )
const char **rest/*out*/, H5G_entry_t *grp_ent/*out*/,
H5G_entry_t *obj_ent/*out*/)
{
H5G_entry_t _grp_ent; /*entry for current group */
H5G_entry_t _obj_ent; /*entry found */
size_t nchars; /*component name length */
char comp[1024]; /*component name buffer */
hbool_t aside = FALSE; /*did we look at a name message? */
H5G_entry_t _grp_ent; /*entry for current group */
H5G_entry_t _obj_ent; /*entry found */
size_t nchars; /*component name length */
char comp[1024]; /*component name buffer */
hbool_t aside = FALSE; /*did we look at a name message?*/
/* clear output args before FUNC_ENTER() in case it fails */
if (rest)
*rest = name;
if (!grp_ent)
grp_ent = &_grp_ent;
if (!obj_ent)
obj_ent = &_obj_ent;
if (rest) *rest = name;
if (!grp_ent) grp_ent = &_grp_ent;
if (!obj_ent) obj_ent = &_obj_ent;
memset(grp_ent, 0, sizeof(H5G_entry_t));
H5F_addr_undef(&(grp_ent->header));
memset(obj_ent, 0, sizeof(H5G_entry_t));
@ -754,15 +831,15 @@ H5G_mkroot(H5F_t *f, size_t size_hint)
*
*-------------------------------------------------------------------------
*/
H5G_t *
H5G_t *
H5G_create(H5F_t *f, const char *name, size_t size_hint)
{
const char *rest = NULL; /*the base name */
H5G_entry_t grp_ent; /*group containing new group */
char _comp[1024]; /*name component */
size_t nchars; /*number of characters in compon */
herr_t status; /*function return status */
H5G_t *grp = NULL; /*new group */
const char *rest = NULL; /*the base name */
H5G_entry_t grp_ent; /*group containing new group */
char _comp[1024]; /*name component */
size_t nchars; /*number of characters in compon*/
herr_t status; /*function return status */
H5G_t *grp = NULL; /*new group */
FUNC_ENTER(H5G_create, NULL);
@ -774,7 +851,7 @@ H5G_create(H5F_t *f, const char *name, size_t size_hint)
* Try to create the root group. Ignore the error if this function
* fails because the root group already exists.
*/
if ((status = H5G_mkroot(f, H5G_SIZE_HINT)) < 0 && -2 != status) {
if ((status=H5G_mkroot(f, H5G_SIZE_HINT))<0 && -2!=status) {
HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create root group");
}
H5E_clear();
@ -801,12 +878,14 @@ H5G_create(H5F_t *f, const char *name, size_t size_hint)
rest = _comp;
}
}
/* create an open group */
grp = H5MM_xcalloc(1, sizeof(H5G_t));
if (H5G_stab_create(f, size_hint, &(grp->ent) /*out */ ) < 0) {
if (H5G_stab_create(f, size_hint, &(grp->ent)/*out*/) < 0) {
grp = H5MM_xfree(grp);
HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create grp");
}
/* insert child name into parent */
if (H5G_stab_insert(&grp_ent, rest, &(grp->ent)) < 0) {
H5O_close(&(grp->ent));

View File

@ -17,7 +17,7 @@
*
*-------------------------------------------------------------------------
*/
#define H5G_PACKAGE /*suppress error message about including H5Gpkg.h */
#define H5G_PACKAGE /*suppress error message about including H5Gpkg.h */
/* Packages needed by this file... */
#include <H5private.h> /*library */
@ -33,64 +33,61 @@
#define PABLO_MASK H5G_node_mask
/* PRIVATE PROTOTYPES */
static herr_t H5G_node_decode_key(H5F_t *f, H5B_t *bt, uint8 *raw,
void *_key);
static herr_t H5G_node_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw,
void *_key);
static size_t H5G_node_size(H5F_t *f);
static herr_t H5G_node_create(H5F_t *f, H5B_ins_t op, void *_lt_key,
void *_udata, void *_rt_key,
haddr_t *addr /*out */ );
static herr_t H5G_node_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr,
H5G_node_t *sym);
static H5G_node_t *H5G_node_load(H5F_t *f, const haddr_t *addr,
const void *_udata1, void *_udata2);
static intn H5G_node_cmp2(H5F_t *f, void *_lt_key, void *_udata,
void *_rt_key);
static intn H5G_node_cmp3(H5F_t *f, void *_lt_key, void *_udata,
void *_rt_key);
static herr_t H5G_node_found(H5F_t *f, const haddr_t *addr,
const void *_lt_key, void *_udata,
const void *_rt_key);
static H5B_ins_t H5G_node_insert(H5F_t *f, const haddr_t *addr,
void *_lt_key, hbool_t *lt_key_changed,
void *_md_key, void *_udata,
void *_rt_key, hbool_t *rt_key_changed,
haddr_t *new_node /*out */ );
static herr_t H5G_node_list(H5F_t *f, const haddr_t *addr, void *_udata);
static size_t H5G_node_sizeof_rkey(H5F_t *f, const void *_udata);
static herr_t H5G_node_decode_key(H5F_t *f, H5B_t *bt, uint8 *raw,
void *_key);
static herr_t H5G_node_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw,
void *_key);
static size_t H5G_node_size(H5F_t *f);
static herr_t H5G_node_create(H5F_t *f, H5B_ins_t op, void *_lt_key,
void *_udata, void *_rt_key,
haddr_t *addr/*out*/);
static herr_t H5G_node_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr,
H5G_node_t *sym);
static H5G_node_t *H5G_node_load(H5F_t *f, const haddr_t *addr,
const void *_udata1, void *_udata2);
static intn H5G_node_cmp2(H5F_t *f, void *_lt_key, void *_udata,
void *_rt_key);
static intn H5G_node_cmp3(H5F_t *f, void *_lt_key, void *_udata,
void *_rt_key);
static herr_t H5G_node_found(H5F_t *f, const haddr_t *addr,
const void *_lt_key, void *_udata,
const void *_rt_key);
static H5B_ins_t H5G_node_insert(H5F_t *f, const haddr_t *addr,
void *_lt_key, hbool_t *lt_key_changed,
void *_md_key, void *_udata,
void *_rt_key, hbool_t *rt_key_changed,
haddr_t *new_node/*out*/);
static herr_t H5G_node_iterate(H5F_t *f, const haddr_t *addr, void *_udata);
static size_t H5G_node_sizeof_rkey(H5F_t *f, const void *_udata);
/* H5G inherits cache-like properties from H5AC */
const H5AC_class_t H5AC_SNODE[1] =
{
{
H5AC_SNODE_ID,
(void *(*)(H5F_t *, const haddr_t *, const void *, void *)) H5G_node_load,
(herr_t (*)(H5F_t *, hbool_t, const haddr_t *, void *)) H5G_node_flush,
}};
const H5AC_class_t H5AC_SNODE[1] = {{
H5AC_SNODE_ID,
(void *(*)(H5F_t*, const haddr_t*, const void*, void*))H5G_node_load,
(herr_t (*)(H5F_t*, hbool_t, const haddr_t*, void*))H5G_node_flush,
}};
/* H5G inherits B-tree like properties from H5B */
H5B_class_t H5B_SNODE[1] =
{
{
H5B_SNODE_ID, /*id */
sizeof(H5G_node_key_t), /*sizeof_nkey */
H5G_node_sizeof_rkey, /*get_sizeof_rkey */
H5G_node_create, /*new */
H5G_node_cmp2, /*cmp2 */
H5G_node_cmp3, /*cmp3 */
H5G_node_found, /*found */
H5G_node_insert, /*insert */
TRUE, /*follow min branch? */
TRUE, /*follow max branch? */
H5G_node_list, /*list */
H5G_node_decode_key, /*decode */
H5G_node_encode_key, /*encode */
}};
H5B_class_t H5B_SNODE[1] = {{
H5B_SNODE_ID, /*id */
sizeof(H5G_node_key_t), /*sizeof_nkey */
H5G_node_sizeof_rkey, /*get_sizeof_rkey */
H5G_node_create, /*new */
H5G_node_cmp2, /*cmp2 */
H5G_node_cmp3, /*cmp3 */
H5G_node_found, /*found */
H5G_node_insert, /*insert */
TRUE, /*follow min branch? */
TRUE, /*follow max branch? */
H5G_node_iterate, /*list */
H5G_node_decode_key, /*decode */
H5G_node_encode_key, /*encode */
}};
/* Interface initialization */
static intn interface_initialize_g = FALSE;
static intn interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
* Function: H5G_node_sizeof_rkey
@ -115,6 +112,7 @@ H5G_node_sizeof_rkey(H5F_t *f, const void *udata __attribute__((unused)))
{
return H5F_SIZEOF_SIZE(f); /*the name offset */
}
/*-------------------------------------------------------------------------
* Function: H5G_node_decode_key
@ -148,6 +146,7 @@ H5G_node_decode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5G_node_encode_key
@ -181,6 +180,7 @@ H5G_node_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5G_node_size
@ -205,6 +205,7 @@ H5G_node_size(H5F_t *f)
return H5G_NODE_SIZEOF_HDR(f) +
(2 * H5G_NODE_K(f)) * H5G_SIZEOF_ENTRY(f);
}
/*-------------------------------------------------------------------------
* Function: H5G_node_create
@ -230,7 +231,7 @@ H5G_node_size(H5F_t *f)
static herr_t
H5G_node_create(H5F_t *f, H5B_ins_t op,
void *_lt_key, void *_udata, void *_rt_key,
haddr_t *addr /*out */ )
haddr_t *addr/*out*/)
{
H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key;
H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key;
@ -247,7 +248,7 @@ H5G_node_create(H5F_t *f, H5B_ins_t op,
sym = H5MM_xcalloc(1, sizeof(H5G_node_t));
size = H5G_node_size(f);
if (H5MF_alloc(f, H5MF_META, size, addr /*out */ ) < 0) {
if (H5MF_alloc(f, H5MF_META, size, addr/*out*/) < 0) {
H5MM_xfree(sym);
HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
"unable to allocate file space");
@ -266,13 +267,12 @@ H5G_node_create(H5F_t *f, H5B_ins_t op,
* allows the comparison functions to work correctly without knowing
* that there are no symbols.
*/
if (lt_key)
lt_key->offset = 0;
if (rt_key)
rt_key->offset = 0;
if (lt_key) lt_key->offset = 0;
if (rt_key) rt_key->offset = 0;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5G_node_flush
@ -295,10 +295,10 @@ static herr_t
H5G_node_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr,
H5G_node_t *sym)
{
uint8 *buf = NULL, *p = NULL;
size_t size;
herr_t status;
int i;
uint8 *buf = NULL, *p = NULL;
size_t size;
herr_t status;
int i;
FUNC_ENTER(H5G_node_flush, FAIL);
@ -313,8 +313,8 @@ H5G_node_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr,
* Look for dirty entries and set the node dirty flag.
*/
for (i = 0; i < sym->nsyms; i++) {
if (sym->entry[i].dirty)
sym->dirty = TRUE;
if (sym->entry[i].dirty)
sym->dirty = TRUE;
}
/*
@ -358,6 +358,7 @@ H5G_node_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr,
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5G_node_load
@ -376,7 +377,7 @@ H5G_node_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr,
*
*-------------------------------------------------------------------------
*/
static H5G_node_t *
static H5G_node_t *
H5G_node_load(H5F_t *f, const haddr_t *addr, const void *_udata1,
void *_udata2)
{
@ -445,6 +446,7 @@ H5G_node_load(H5F_t *f, const haddr_t *addr, const void *_udata1,
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5G_node_cmp2
@ -496,6 +498,7 @@ H5G_node_cmp2(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
FUNC_LEAVE(cmp);
}
/*-------------------------------------------------------------------------
* Function: H5G_node_cmp3
@ -552,6 +555,7 @@ H5G_node_cmp3(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
FUNC_LEAVE(0);
}
/*-------------------------------------------------------------------------
* Function: H5G_node_found
@ -585,11 +589,11 @@ static herr_t
H5G_node_found(H5F_t *f, const haddr_t *addr, const void *_lt_key,
void *_udata, const void *_rt_key)
{
H5G_bt_ud1_t *bt_udata = (H5G_bt_ud1_t *) _udata;
H5G_node_t *sn = NULL;
intn lt = 0, idx = 0, rt, cmp = 1;
const char *s;
herr_t ret_value = FAIL;
H5G_bt_ud1_t *bt_udata = (H5G_bt_ud1_t *) _udata;
H5G_node_t *sn = NULL;
intn lt = 0, idx = 0, rt, cmp = 1;
const char *s;
herr_t ret_value = FAIL;
FUNC_ENTER(H5G_node_found, FAIL);
@ -607,6 +611,7 @@ H5G_node_found(H5F_t *f, const haddr_t *addr, const void *_lt_key,
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL,
"unable to protect symbol table node");
}
/*
* Binary search.
*/
@ -639,8 +644,8 @@ H5G_node_found(H5F_t *f, const haddr_t *addr, const void *_lt_key,
break;
default:
HRETURN_ERROR(H5E_SYM, H5E_UNSUPPORTED, FAIL,
"internal erorr (unknown symbol find operation)");
HRETURN_ERROR(H5E_SYM, H5E_UNSUPPORTED, FAIL,
"internal erorr (unknown symbol find operation)");
}
ret_value = SUCCEED;
@ -651,6 +656,7 @@ H5G_node_found(H5F_t *f, const haddr_t *addr, const void *_lt_key,
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5G_node_insert
@ -726,6 +732,7 @@ H5G_node_insert(H5F_t *f, const haddr_t *addr,
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR,
"unable to protect symbol table node");
}
/*
* Where does the new symbol get inserted? We use a binary search.
*/
@ -832,12 +839,12 @@ H5G_node_insert(H5F_t *f, const haddr_t *addr,
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5G_node_list
* Function: H5G_node_iterate
*
* Purpose: This function gets called during a group list operation.
* It should fill in data in the UDATA struct.
* Purpose: This function gets called during a group iterate operation.
*
* Return: Success: SUCCEED
*
@ -852,15 +859,17 @@ H5G_node_insert(H5F_t *f, const haddr_t *addr,
*-------------------------------------------------------------------------
*/
static herr_t
H5G_node_list(H5F_t *f, const haddr_t *addr, void *_udata)
H5G_node_iterate (H5F_t *f, const haddr_t *addr, void *_udata)
{
H5G_bt_ud2_t *bt_udata = (H5G_bt_ud2_t *) _udata;
H5G_node_t *sn = NULL;
intn i;
const char *s;
herr_t ret_value = FAIL;
H5G_bt_ud2_t *bt_udata = (H5G_bt_ud2_t *)_udata;
H5G_node_t *sn = NULL;
intn i, nsyms;
size_t n, *name_off=NULL;
const char *name;
char buf[1024], *s;
herr_t ret_value = FAIL;
FUNC_ENTER(H5G_node_list, FAIL);
FUNC_ENTER(H5G_node_iterate, FAIL);
/*
* Check arguments.
@ -869,50 +878,46 @@ H5G_node_list(H5F_t *f, const haddr_t *addr, void *_udata)
assert(addr && H5F_addr_defined(addr));
assert(bt_udata);
if (NULL == (sn = H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL))) {
/*
* Save information about the symbol table node since we can't lock it
* because we're about to call an application function.
*/
if (NULL == (sn = H5AC_find(f, H5AC_SNODE, addr, NULL, NULL))) {
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL,
"unable to protect symbol table node");
"unable to load symbol table node");
}
nsyms = sn->nsyms;
name_off = H5MM_xmalloc (nsyms*sizeof(name_off[0]));
for (i=0; i<nsyms; i++) name_off[i] = sn->entry[i].name_off;
sn = NULL;
/*
* If we've already overflowed the user-supplied buffer, then just
* keep track of how many names we've seen and don't bother doing
* anything else.
* Iterate over the symbol table node entries.
*/
if (bt_udata->nsyms >= bt_udata->maxentries) {
bt_udata->nsyms += sn->nsyms;
HGOTO_DONE(SUCCEED);
}
/*
* Save the symbol table entries.
*/
if (bt_udata->entry) {
for (i = 0; i < sn->nsyms && bt_udata->nsyms + i < bt_udata->maxentries; i++) {
bt_udata->entry[bt_udata->nsyms + i] = sn->entry[i];
for (i=0, ret_value=0; i<nsyms && 0==ret_value; i++) {
if (bt_udata->skip>0) {
--bt_udata->skip;
} else {
name = H5H_peek (f, &(bt_udata->group->ent.cache.stab.heap_addr),
name_off[i]);
assert (name);
n = strlen (name);
s = n+1>sizeof(buf) ? H5MM_xmalloc (n+1) : buf;
strcpy (s, name);
ret_value = (bt_udata->op)(bt_udata->group_id, s,
bt_udata->op_data);
if (s!=buf) H5MM_xfree (s);
}
}
if (bt_udata->name) {
for (i = 0; i < sn->nsyms && bt_udata->nsyms + i < bt_udata->maxentries; i++) {
if (NULL == (s = H5H_peek(f, &(bt_udata->heap_addr),
sn->entry[i].name_off))) {
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
"unable to read symbol name");
}
bt_udata->name[bt_udata->nsyms + i] = H5MM_xstrdup(s);
}
if (ret_value<0) {
HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed");
}
/*
* Update the number of symbols.
*/
bt_udata->nsyms += sn->nsyms;
ret_value = SUCCEED;
done:
if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn) < 0) {
HRETURN_ERROR(H5E_CACHE, H5E_PROTECT, FAIL,
"unable to release symbol table node");
}
name_off = H5MM_xfree (name_off);
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5G_node_debug

View File

@ -93,19 +93,18 @@ typedef struct H5G_bt_ud1_t {
/*
* Data exchange structure to pass through the B-tree layer for the
* H5B_list function.
* H5B_iterate function.
*/
typedef struct H5G_bt_ud2_t {
/* downward */
H5G_entry_t *entry; /*array of entries, alloc'd by caller */
char **name; /*array of string ptrs, allocd by caller */
intn maxentries; /*size of the ADDR and NAME arrays */
haddr_t heap_addr; /*heap address */
hid_t group_id; /*group id to pass to iteration operator */
struct H5G_t *group; /*the group to which group_id points */
int skip; /*initial entries to skip */
H5G_iterate_t op; /*iteration operator */
void *op_data; /*user-defined operator data */
/* upward */
intn nsyms; /*num. symbols processed */
} H5G_bt_ud2_t;
/*
@ -126,9 +125,6 @@ herr_t H5G_stab_find (H5G_entry_t *grp_ent, const char *name,
H5G_entry_t *obj_ent/*out*/);
herr_t H5G_stab_insert (H5G_entry_t *grp_ent, const char *name,
H5G_entry_t *obj_ent);
intn H5G_stab_list (H5G_entry_t *self, intn maxentries, char *names[]/*out*/,
H5G_entry_t entries[]/*out*/);
/*
* Functions that understand symbol table entries.
*/

View File

@ -27,12 +27,17 @@
extern "C" {
#endif
typedef herr_t (*H5G_iterate_t)(hid_t group, const char *group_name,
void *op_data);
hid_t H5Gcreate (hid_t file_id, const char *name, size_t size_hint);
hid_t H5Gopen (hid_t file_id, const char *name);
herr_t H5Gclose (hid_t grp_id);
herr_t H5Gset (hid_t file, const char *name);
herr_t H5Gpush (hid_t file, const char *name);
herr_t H5Gpop (hid_t file);
herr_t H5Giterate (hid_t file, const char *name, int *idx, H5G_iterate_t op,
void *op_data);
#ifdef __cplusplus
}

View File

@ -47,7 +47,7 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
herr_t
H5G_stab_create(H5F_t *f, size_t init, H5G_entry_t *self /*out */ )
H5G_stab_create(H5F_t *f, size_t init, H5G_entry_t *self/*out*/)
{
size_t name; /*offset of "" name */
H5O_stab_t stab; /*symbol table message */
@ -207,71 +207,3 @@ H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent)
obj_ent->name_off = udata.ent.name_off;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5G_stab_list
*
* Purpose: Returns a list of all the symbols in a symbol table.
* The caller allocates an array of pointers which this
* function will fill in with malloc'd names. The caller
* also allocates an array of symbol table entries which will
* be filled in with data from the symbol table. Each of these
* arrays should have at least MAXENTRIES elements.
*
* Errors:
* SYM BADMESG Not a symbol table.
* SYM CANTLIST B-tree list failure.
*
* Return: Success: The total number of symbols in the
* symbol table. This may exceed MAXENTRIES,
* but at most MAXENTRIES values are copied
* into the NAMES and ENTRIES arrays.
*
* Failure: FAIL, the pointers in NAMES are undefined but
* no memory is allocated. The values in
* ENTRIES are undefined.
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Aug 1 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
intn
H5G_stab_list(H5G_entry_t *grp_ent, intn maxentries, char *names[] /*out */ ,
H5G_entry_t entries[] /*out */ )
{
H5G_bt_ud2_t udata;
H5O_stab_t stab;
intn i;
FUNC_ENTER(H5G_stab_list, FAIL);
/* check args */
assert(grp_ent && grp_ent->file);
assert(maxentries >= 0);
/* initialize data to pass through B-tree */
if (NULL == H5O_read(grp_ent, H5O_STAB, 0, &stab)) {
HRETURN_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
}
udata.entry = entries;
udata.name = names;
udata.heap_addr = stab.heap_addr;
udata.maxentries = maxentries;
udata.nsyms = 0;
if (names)
HDmemset(names, 0, maxentries);
/* list */
if (H5B_list(grp_ent->file, H5B_SNODE, &(stab.btree_addr), &udata) < 0) {
if (names) {
for (i = 0; i < maxentries; i++)
H5MM_xfree(names[i]);
}
HRETURN_ERROR(H5E_SYM, H5E_CANTLIST, FAIL, "b-tree list failure");
}
FUNC_LEAVE(udata.nsyms);
}

View File

@ -516,6 +516,9 @@ H5O_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
/* encode body size */
UINT32ENCODE(p, oh->chunk[0].size);
/* zero to alignment */
HDmemset (p, 0, H5O_SIZEOF_HDR(f)-12);
/* write the object header header */
if (H5F_block_write(f, addr, H5O_SIZEOF_HDR(f), buf) < 0) {
HRETURN_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL,

View File

@ -559,7 +559,9 @@ main(int argc, char *argv[])
size_of_test |= TEST_LARGE;
} else {
printf("unrecognized argument: %s\n", argv[i]);
#if 0
exit(1);
#endif
}
}
}