summaryrefslogtreecommitdiffstats
path: root/src/H5Gstab.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-08-08 16:52:55 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-08-08 16:52:55 (GMT)
commitd8397a6f426227d09d20e647ce8b12b8c6295b2d (patch)
tree2943fbfd2bfb66cf167eb642835fdb4deb3afd3c /src/H5Gstab.c
parent573307786a1f5f7ce597e5191ea08c3bbd95b66c (diff)
downloadhdf5-d8397a6f426227d09d20e647ce8b12b8c6295b2d.zip
hdf5-d8397a6f426227d09d20e647ce8b12b8c6295b2d.tar.gz
hdf5-d8397a6f426227d09d20e647ce8b12b8c6295b2d.tar.bz2
[svn-r5842] Purpose:
Code cleanup Description: Change most (all?) HRETURN_ERROR macros to HGOTO_ERROR macros, along with HRETURN macros to HGOTO_DONE macros. This unifies the error return path from functions and reduces the size of the library by up to 10% on some platforms. Additionally, I improved a lot of the error cleanup code in many routines. Platforms tested: FreeBSD 4.6 (sleipnir) serial & parallel and IRIX64 6.5 (modi4) serial & parallel.
Diffstat (limited to 'src/H5Gstab.c')
-rw-r--r--src/H5Gstab.c83
1 files changed, 42 insertions, 41 deletions
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index 9a23256..9c4311c 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -20,6 +20,7 @@
#define PABLO_MASK H5G_stab_mask
static int interface_initialize_g = 0;
#define INTERFACE_INIT NULL
+
/*-------------------------------------------------------------------------
* Function: H5G_stab_create
@@ -50,6 +51,7 @@ 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 */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_create, FAIL);
@@ -61,13 +63,11 @@ H5G_stab_create(H5F_t *f, size_t init, H5G_entry_t *self/*out*/)
init = MAX(init, H5HL_SIZEOF_FREE(f) + 2);
/* Create symbol table private heap */
- if (H5HL_create(f, init, &(stab.heap_addr)/*out*/)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap");
- }
+ if (H5HL_create(f, init, &(stab.heap_addr)/*out*/)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap");
name = H5HL_insert(f, stab.heap_addr, 1, "");
- if ((size_t)(-1)==name) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't initialize heap");
- }
+ if ((size_t)(-1)==name)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't initialize heap");
/*
* B-tree's won't work if the first name isn't at the beginning
@@ -76,18 +76,16 @@ H5G_stab_create(H5F_t *f, size_t init, H5G_entry_t *self/*out*/)
assert(0 == name);
/* Create the B-tree */
- if (H5B_create(f, H5B_SNODE, NULL, &(stab.btree_addr)/*out*/) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create B-tree");
- }
+ if (H5B_create(f, H5B_SNODE, NULL, &(stab.btree_addr)/*out*/) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create B-tree");
/*
* Create symbol table object header. It has a zero link count
* since nothing refers to it yet. The link count will be
* incremented if the object is added to the group directed graph.
*/
- if (H5O_create(f, 4 + 2 * H5F_SIZEOF_ADDR(f), self/*out*/) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header");
- }
+ if (H5O_create(f, 4 + 2 * H5F_SIZEOF_ADDR(f), self/*out*/) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header");
/*
* Insert the symbol table message into the object header and the symbol
@@ -95,13 +93,14 @@ H5G_stab_create(H5F_t *f, size_t init, H5G_entry_t *self/*out*/)
*/
if (H5O_modify(self, H5O_STAB, H5O_NEW_MESG, H5O_FLAG_CONSTANT, &stab)<0) {
H5O_close(self);
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message");
}
self->cache.stab.btree_addr = stab.btree_addr;
self->cache.stab.heap_addr = stab.heap_addr;
self->type = H5G_CACHED_STAB;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -130,6 +129,7 @@ H5G_stab_find(H5G_entry_t *grp_ent, const char *name,
{
H5G_bt_ud1_t udata; /*data to pass through B-tree */
H5O_stab_t stab; /*symbol table message */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_find, FAIL);
@@ -139,20 +139,22 @@ H5G_stab_find(H5G_entry_t *grp_ent, const char *name,
assert(name && *name);
/* set up the udata */
- if (NULL == H5O_read(grp_ent, H5O_STAB, 0, &stab)) {
- HRETURN_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't read message");
- }
+ if (NULL == H5O_read(grp_ent, H5O_STAB, 0, &stab))
+ HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't read message");
udata.operation = H5G_OPER_FIND;
udata.name = name;
udata.heap_addr = stab.heap_addr;
/* search the B-tree */
- if (H5B_find(grp_ent->file, H5B_SNODE, stab.btree_addr, &udata) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
- }
- if (obj_ent) *obj_ent = udata.ent;
- FUNC_LEAVE(SUCCEED);
+ if (H5B_find(grp_ent->file, H5B_SNODE, stab.btree_addr, &udata) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
+ if (obj_ent)
+ *obj_ent = udata.ent;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5G_stab_insert
@@ -179,6 +181,7 @@ H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent)
H5O_stab_t stab; /*symbol table message */
H5G_bt_ud1_t udata; /*data to pass through B-tree */
static double split_ratios[3] = {0.1, 0.5, 0.9};
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_insert, FAIL);
@@ -186,29 +189,26 @@ H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent)
assert(grp_ent && grp_ent->file);
assert(name && *name);
assert(obj_ent && obj_ent->file);
- if (grp_ent->file->shared != obj_ent->file->shared) {
- HRETURN_ERROR(H5E_SYM, H5E_LINK, FAIL,
- "interfile hard links are not allowed");
- }
+ if (grp_ent->file->shared != obj_ent->file->shared)
+ HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "interfile hard links are not allowed");
/* 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");
- }
+ if (NULL == H5O_read(grp_ent, H5O_STAB, 0, &stab))
+ HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
udata.operation = H5G_OPER_INSERT;
udata.name = name;
udata.heap_addr = stab.heap_addr;
udata.ent = *obj_ent;
/* insert */
- if (H5B_insert(grp_ent->file, H5B_SNODE, stab.btree_addr, split_ratios,
- &udata) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert entry");
- }
+ if (H5B_insert(grp_ent->file, H5B_SNODE, stab.btree_addr, split_ratios, &udata) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert entry");
/* update the name offset in the entry */
obj_ent->name_off = udata.ent.name_off;
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -231,6 +231,7 @@ H5G_stab_remove(H5G_entry_t *grp_ent, const char *name)
{
H5O_stab_t stab; /*symbol table message */
H5G_bt_ud1_t udata; /*data to pass through B-tree */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_remove, FAIL);
@@ -238,18 +239,18 @@ H5G_stab_remove(H5G_entry_t *grp_ent, const char *name)
assert(name && *name);
/* 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");
- }
+ if (NULL==H5O_read(grp_ent, H5O_STAB, 0, &stab))
+ HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
udata.operation = H5G_OPER_REMOVE;
udata.name = name;
udata.heap_addr = stab.heap_addr;
HDmemset(&(udata.ent), 0, sizeof(udata.ent));
/* remove */
- if (H5B_remove(grp_ent->file, H5B_SNODE, stab.btree_addr, &udata)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry");
- }
+ if (H5B_remove(grp_ent->file, H5B_SNODE, stab.btree_addr, &udata)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry");
+
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}