diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5A.c | 71 | ||||
-rw-r--r-- | src/H5Adense.c | 424 | ||||
-rw-r--r-- | src/H5Adeprec.c | 4 | ||||
-rw-r--r-- | src/H5Apkg.h | 33 | ||||
-rw-r--r-- | src/H5G.c | 4 | ||||
-rw-r--r-- | src/H5Gcompact.c | 14 | ||||
-rw-r--r-- | src/H5Gdense.c | 68 | ||||
-rw-r--r-- | src/H5Gdeprec.c | 4 | ||||
-rw-r--r-- | src/H5Glink.c | 8 | ||||
-rw-r--r-- | src/H5Gloc.c | 4 | ||||
-rw-r--r-- | src/H5Gname.c | 2 | ||||
-rw-r--r-- | src/H5Gobj.c | 29 | ||||
-rw-r--r-- | src/H5Gpkg.h | 32 | ||||
-rw-r--r-- | src/H5Gprivate.h | 2 | ||||
-rw-r--r-- | src/H5Gpublic.h | 2 | ||||
-rw-r--r-- | src/H5Gstab.c | 2 | ||||
-rw-r--r-- | src/H5L.c | 44 | ||||
-rw-r--r-- | src/H5Lpublic.h | 21 | ||||
-rw-r--r-- | src/H5O.c | 8 | ||||
-rw-r--r-- | src/H5Oattr.c | 9 | ||||
-rw-r--r-- | src/H5Oattribute.c | 269 | ||||
-rw-r--r-- | src/H5Olinfo.c | 2 | ||||
-rw-r--r-- | src/H5Omessage.c | 13 | ||||
-rw-r--r-- | src/H5Opkg.h | 3 | ||||
-rw-r--r-- | src/H5Opublic.h | 4 | ||||
-rw-r--r-- | src/H5Ppublic.h | 1 | ||||
-rw-r--r-- | src/H5public.h | 12 | ||||
-rw-r--r-- | src/H5trace.c | 317 |
28 files changed, 1029 insertions, 377 deletions
@@ -72,7 +72,6 @@ static H5A_t *H5A_open_by_name(const H5G_loc_t *loc, const char *name, hid_t dxpl_id); static herr_t H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id); static herr_t H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id); -static int H5A_get_index(H5O_loc_t *loc, const char *name, hid_t dxpl_id); static hsize_t H5A_get_storage_size(const H5A_t *attr); static herr_t H5A_find_idx_by_name(const void *mesg, unsigned idx, void *op_data); @@ -312,6 +311,7 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, /* Iterate over the existing attributes to check for duplicates */ cb.name = name; cb.idx = (-1); +/* XXX: Add support/test for dense attribute storage */ if((ret_value = H5O_msg_iterate(loc->oloc, H5O_ATTR_ID, H5A_find_idx_by_name, &cb, dxpl_id)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "error iterating over attributes") if(ret_value > 0) @@ -433,9 +433,8 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, done: /* Cleanup on failure */ - if(ret_value < 0) - if(attr) - (void)H5A_close(attr); + if(ret_value < 0 && attr) + (void)H5A_close(attr); FUNC_LEAVE_NOAPI(ret_value) } /* H5A_create() */ @@ -487,49 +486,6 @@ H5A_find_idx_by_name(const void *_mesg, unsigned idx, void *_op_data) /*-------------------------------------------------------------------------- NAME - H5A_get_index - PURPOSE - Determine the index of an attribute in an object header - USAGE - int H5A_get_index (ent, name) - H5O_loc_t *loc; IN: Object location - const char *name; IN: Name of dataset to find - RETURNS - non-negative on success, negative on failure - - DESCRIPTION - This function determines the index of the attribute within an object - header. This is not stored in the attribute structure because it is only - a subjective measure and can change if attributes are deleted from the - object header. ---------------------------------------------------------------------------*/ -static int -H5A_get_index(H5O_loc_t *loc, const char *name, hid_t dxpl_id) -{ - H5A_iter_cb1 udata; /* Iterator callback info */ - int ret_value = FAIL; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5A_get_index) - - HDassert(loc); - HDassert(name); - - udata.name = name; - udata.idx = (-1); - if((ret_value = H5O_msg_iterate(loc, H5O_ATTR_ID, H5A_find_idx_by_name, &udata, dxpl_id)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "error iterating over attributes") - if(ret_value > 0) - ret_value = udata.idx; - else - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "attribute not found") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5A_get_index() */ - - -/*-------------------------------------------------------------------------- - NAME H5Aopen_name PURPOSE Opens an attribute for an object by looking up the attribute name @@ -686,9 +642,8 @@ H5A_open(H5G_loc_t *loc, unsigned idx, hid_t dxpl_id) done: /* Cleanup on failure */ - if(ret_value < 0) - if(attr) - (void)H5A_close(attr); + if(ret_value < 0 && attr) + (void)H5A_close(attr); FUNC_LEAVE_NOAPI(ret_value) } /* H5A_open() */ @@ -1481,8 +1436,7 @@ herr_t H5Adelete(hid_t loc_id, const char *name) { H5G_loc_t loc; /* Object location */ - int found; - herr_t ret_value; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Adelete, FAIL) H5TRACE2("e","is",loc_id,name); @@ -1495,13 +1449,9 @@ H5Adelete(hid_t loc_id, const char *name) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - /* Look up the attribute index for the object */ - if((found = H5A_get_index(loc.oloc, name, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "attribute not found") - /* Delete the attribute from the location */ - if((ret_value = H5O_msg_remove(loc.oloc, H5O_ATTR_ID, found, TRUE, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute header message") + if(H5O_attr_remove(loc.oloc, name, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: FUNC_LEAVE_API(ret_value) @@ -1592,7 +1542,7 @@ H5A_copy(H5A_t *_new_attr, const H5A_t *old_attr) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "unable to copy attribute datatype") if(NULL == (new_attr->ds = H5S_copy(old_attr->ds, FALSE))) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "unable to copy attribute dataspace") - /* XXX: Copy the object location and group path? -QAK */ +/* XXX: Copy the object location and group path? -QAK */ /* Copy the attribute data, if there is any */ if(old_attr->data) { @@ -1638,12 +1588,11 @@ H5A_free(H5A_t *attr) FUNC_ENTER_NOAPI(H5A_free, FAIL) - assert(attr); + HDassert(attr); /* Free dynamicly allocated items */ if(attr->name) H5MM_xfree(attr->name); - if(attr->dt) if(H5T_close(attr->dt) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release datatype info") diff --git a/src/H5Adense.c b/src/H5Adense.c index b374e79..9d98dc0 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -38,6 +38,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ #include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ @@ -72,6 +73,12 @@ /* Local Typedefs */ /******************/ +/* Data exchange structure to use when building table of attributes for an object */ +typedef struct { + H5A_attr_table_t *atable; /* Pointer to attribute table to build */ + size_t curr_attr; /* Current attribute to operate on */ +} H5A_dense_bt_ud_t; + /* * Data exchange structure for dense attribute storage. This structure is * passed through the v2 B-tree layer when modifying attributes. @@ -84,7 +91,6 @@ typedef struct H5A_bt2_od_wrt_t { size_t attr_size; /* Size of encode attribute */ } H5A_bt2_od_wrt_t; - /* * Data exchange structure to pass through the v2 B-tree layer for the * H5B2_iterate function when iterating over densely stored attributes. @@ -99,7 +105,7 @@ typedef struct { hid_t loc_id; /* Object ID for application callback */ unsigned skip; /* Number of attributes to skip */ unsigned count; /* The # of attributes visited */ - H5A_operator_t op; /* Callback for each attribute */ + const H5A_attr_iterate_t *attr_op; /* Callback for each attribute */ void *op_data; /* Callback data for each attribute */ /* upward */ @@ -119,6 +125,16 @@ typedef struct { H5A_t *attr; /* Copy of attribute */ } H5A_fh_ud_it_t; +/* + * Data exchange structure to pass through the fractal heap layer for the + * H5HF_op function when removing an attribute from densely stored attributes. + */ +typedef struct { + /* downward */ + H5F_t *f; /* Pointer to file that fractal heap is in */ + hid_t dxpl_id; /* DXPL for operation */ +} H5A_fh_ud_rm_t; + /********************/ /* Package Typedefs */ @@ -129,6 +145,8 @@ typedef struct { /* Local Prototypes */ /********************/ +static herr_t H5A_attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, + H5_iter_order_t order); /*********************/ /* Package Variables */ @@ -150,6 +168,240 @@ H5FL_BLK_DEFINE(ser_attr); /*------------------------------------------------------------------------- + * Function: H5A_dense_build_table_cb + * + * Purpose: Callback routine for building table of attributes from dense + * attribute storage. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 11 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5A_dense_build_table_cb(const H5A_t *attr, uint8_t mesg_flags, void *_udata) +{ + H5A_dense_bt_ud_t *udata = (H5A_dense_bt_ud_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5A_dense_build_table_cb) + + /* check arguments */ + HDassert(attr); + HDassert(udata); + HDassert(udata->curr_attr < udata->atable->nattrs); + + /* Copy attribute information */ + if(NULL == H5A_copy(&udata->atable->attrs[udata->curr_attr], attr)) + HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute") + udata->atable->flags[udata->curr_attr] = mesg_flags; + + /* Increment number of attributes stored */ + udata->curr_attr++; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5A_dense_build_table_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5A_dense_build_table + * + * Purpose: Builds a table containing a sorted list of attributes for + * an object + * + * Note: Used for building table of attributes in non-native iteration + * order for an index + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Dec 11, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5A_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, + H5_index_t UNUSED idx_type, H5_iter_order_t UNUSED order, + H5A_attr_table_t *atable) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5A_dense_build_table) + + /* Sanity check */ + HDassert(f); + HDassert(oh); + HDassert(atable); + + /* Set size of table */ + H5_CHECK_OVERFLOW(oh->nattrs, /* From: */ hsize_t, /* To: */ size_t); + atable->nattrs = (size_t)oh->nattrs; + + /* Allocate space for the table entries */ + if(atable->nattrs > 0) { + H5A_dense_bt_ud_t udata; /* User data for iteration callback */ + H5A_attr_iterate_t attr_op; /* Attribute operator */ + + /* Allocate the table to store the attributes */ + if((atable->attrs = H5MM_malloc(sizeof(H5A_t) * atable->nattrs)) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if((atable->flags = H5MM_malloc(sizeof(uint8_t) * atable->nattrs)) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Set up user data for iteration */ + udata.atable = atable; + udata.curr_attr = 0; + + /* Build iterator operator */ + attr_op.op_type = H5A_ATTR_OP_LIB; + attr_op.u.lib_op = H5A_dense_build_table_cb; + + /* Iterate over the links in the group, building a table of the link messages */ + if(H5A_dense_iterate(f, dxpl_id, (hid_t)0, oh->attr_fheap_addr, oh->name_bt2_addr, + (unsigned)0, NULL, &attr_op, &udata) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "error building attribute table") + + /* Sort attribute table in correct iteration order */ + if(H5A_attr_sort_table(atable, H5_INDEX_NAME, H5_ITER_INC) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting attribute table") + } /* end if */ + else + atable->attrs = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5A_dense_build_table() */ + + +/*------------------------------------------------------------------------- + * Function: H5A_attr_cmp_name_inc + * + * Purpose: Callback routine for comparing two attribute names, in + * increasing alphabetic order + * + * Return: An integer less than, equal to, or greater than zero if the + * first argument is considered to be respectively less than, + * equal to, or greater than the second. If two members compare + * as equal, their order in the sorted array is undefined. + * (i.e. same as strcmp()) + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 11 2005 + * + *------------------------------------------------------------------------- + */ +static int +H5A_attr_cmp_name_inc(const void *attr1, const void *attr2) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_attr_cmp_name_inc) + + FUNC_LEAVE_NOAPI(HDstrcmp(((const H5A_t *)attr1)->name, ((const H5A_t *)attr2)->name)) +} /* end H5A_attr_cmp_name_inc() */ + + +/*------------------------------------------------------------------------- + * Function: H5A_attr_sort_table + * + * Purpose: Sort table containing a list of attributes for an object + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Dec 11, 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5A_attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type, + H5_iter_order_t order) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_attr_sort_table) + + /* Sanity check */ + HDassert(atable); + + /* Pick appropriate sorting routine */ +#ifdef NOT_YET + if(idx_type == H5_INDEX_NAME) { + if(order == H5_ITER_INC) +#else /* NOT_YET */ +HDassert(idx_type == H5_INDEX_NAME); +HDassert(order == H5_ITER_INC); +#endif /* NOT_YET */ + HDqsort(atable->attrs, atable->nattrs, sizeof(H5A_t), H5A_attr_cmp_name_inc); +#ifdef NOT_YET + else if(order == H5_ITER_DEC) + HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_name_dec); + else + HDassert(order == H5_ITER_NATIVE); + } /* end if */ + else { + HDassert(idx_type == H5_INDEX_CRT_ORDER); + if(order == H5_ITER_INC) + HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_corder_inc); + else if(order == H5_ITER_DEC) + HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_corder_dec); + else + HDassert(order == H5_ITER_NATIVE); + } /* end else */ +#endif /* NOT_YET */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5A_attr_sort_table() */ + + +/*------------------------------------------------------------------------- + * Function: H5A_attr_release_table + * + * Purpose: Release table containing a list of attributes for an object + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Dec 11, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5A_attr_release_table(H5A_attr_table_t *atable) +{ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5A_attr_release_table) + + /* Sanity check */ + HDassert(atable); + + /* Release attribute info, if any */ + if(atable->nattrs > 0) { + /* Free attribute message information */ + for(u = 0; u < atable->nattrs; u++) + if(H5A_free(&(atable->attrs[u])) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release attribute") + + /* Free table of attributes */ + H5MM_xfree(atable->attrs); + H5MM_xfree(atable->flags); + } /* end if */ + else + HDassert(atable->attrs == NULL); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5A_attr_release_table() */ + + +/*------------------------------------------------------------------------- * Function: H5A_dense_create * * Purpose: Creates dense attribute storage structures for an object @@ -666,8 +918,17 @@ HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, H5_ITER_ERROR, "iterating over shared att H5A_dense_iterate_fh_cb, &fh_udata) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPERATE, H5_ITER_ERROR, "heap op callback failed") - /* Make the callback */ - ret_value = (bt2_udata->op)(bt2_udata->loc_id, fh_udata.attr->name, bt2_udata->op_data); + /* Check which type of callback to make */ + switch(bt2_udata->attr_op->op_type) { + case H5A_ATTR_OP_APP: + /* Make the application callback */ + ret_value = (bt2_udata->attr_op->u.app_op)(bt2_udata->loc_id, fh_udata.attr->name, bt2_udata->op_data); + break; + + case H5A_ATTR_OP_LIB: + /* Call the library's callback */ + ret_value = (bt2_udata->attr_op->u.lib_op)(fh_udata.attr, record->flags, bt2_udata->op_data); + } /* end switch */ /* Release the space allocated for the attribute */ H5O_msg_free(H5O_ATTR_ID, fh_udata.attr); @@ -701,8 +962,8 @@ done: */ herr_t H5A_dense_iterate(H5F_t *f, hid_t dxpl_id, hid_t loc_id, haddr_t attr_fheap_addr, - haddr_t name_bt2_addr, unsigned skip, unsigned *last_attr, H5A_operator_t op, - void *op_data) + haddr_t name_bt2_addr, unsigned skip, unsigned *last_attr, + const H5A_attr_iterate_t *attr_op, void *op_data) { H5A_bt2_ud_it_t udata; /* User data for iterator callback */ H5HF_t *fheap = NULL; /* Fractal heap handle */ @@ -716,7 +977,7 @@ H5A_dense_iterate(H5F_t *f, hid_t dxpl_id, hid_t loc_id, haddr_t attr_fheap_addr HDassert(f); HDassert(H5F_addr_defined(attr_fheap_addr)); HDassert(H5F_addr_defined(name_bt2_addr)); - HDassert(op); + HDassert(attr_op); /* Check for skipping too many links */ if(skip > 0) { @@ -743,7 +1004,7 @@ H5A_dense_iterate(H5F_t *f, hid_t dxpl_id, hid_t loc_id, haddr_t attr_fheap_addr udata.loc_id = loc_id; udata.skip = skip; udata.count = 0; - udata.op = op; + udata.attr_op = attr_op; udata.op_data = op_data; /* Iterate over the records in the v2 B-tree's "native" order */ @@ -766,6 +1027,151 @@ done: /*------------------------------------------------------------------------- + * Function: H5A_dense_remove_fh_cb + * + * Purpose: Callback for fractal heap operator when removing attributes + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 11 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5A_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata) +{ + H5A_fh_ud_rm_t *udata = (H5A_fh_ud_rm_t *)_udata; /* User data for fractal heap 'op' callback */ + H5A_t *attr = NULL; /* Pointer to attribute created from heap object */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5A_dense_remove_fh_cb) + + /* Decode attribute */ + if(NULL == (attr = H5O_msg_decode(udata->f, udata->dxpl_id, H5O_ATTR_ID, obj))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, FAIL, "can't decode attribute") + + /* Perform the deletion action on the attribute */ + /* (takes care of shared & committed datatype/dataspace components) */ + if(H5O_attr_delete(udata->f, udata->dxpl_id, attr, TRUE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + +done: + /* Release the space allocated for the message */ + if(attr) + H5O_msg_free_real(H5O_MSG_ATTR, attr); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5A_dense_remove_fh_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5A_dense_remove_bt2_cb + * + * Purpose: v2 B-tree callback for dense attribute storage record removal + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 11 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5A_dense_remove_bt2_cb(const void *_record, void *_bt2_udata) +{ + const H5A_dense_bt2_name_rec_t *record = (const H5A_dense_bt2_name_rec_t *)_record; + H5A_bt2_ud_common_t *bt2_udata = (H5A_bt2_ud_common_t *)_bt2_udata; /* User data for callback */ + H5A_fh_ud_rm_t fh_udata; /* User data for fractal heap 'op' callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5A_dense_remove_bt2_cb) + + /* Check for insertin shared attribute */ + if(record->flags & H5O_MSG_FLAG_SHARED) { +/* XXX: fix me */ +HDfprintf(stderr, "%s: removing shared attributes in dense storage not supported yet!\n", FUNC); +HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "removing shared attributes in dense storage not supported yet") + } /* end if */ + + /* Set up the user data for fractal heap 'op' callback */ + fh_udata.f = bt2_udata->f; + fh_udata.dxpl_id = bt2_udata->dxpl_id; + + /* Call fractal heap 'op' routine, to perform user callback */ + if(H5HF_op(bt2_udata->fheap, bt2_udata->dxpl_id, record->id, + H5A_dense_remove_fh_cb, &fh_udata) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPERATE, FAIL, "attribute removal callback failed") + + /* Remove record from fractal heap */ + if(H5HF_remove(bt2_udata->fheap, bt2_udata->dxpl_id, record->id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from fractal heap") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5A_dense_remove_bt2_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5A_dense_remove + * + * Purpose: Remove an attribute from the dense storage of an object + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 11 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5A_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, const char *name) +{ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5A_bt2_ud_common_t udata; /* User data for v2 B-tree record removal */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5A_dense_remove, FAIL) + + /* + * Check arguments. + */ + HDassert(f); + HDassert(oh); + HDassert(name && *name); + + /* Open the fractal heap */ + if(NULL == (fheap = H5HF_open(f, dxpl_id, oh->attr_fheap_addr))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap") + + /* Set up the user data for the v2 B-tree 'record remove' callback */ + udata.f = f; + udata.dxpl_id = dxpl_id; + udata.fheap = fheap; + udata.name = name; + udata.name_hash = H5_checksum_lookup3(name, HDstrlen(name), 0); + udata.flags = 0; + udata.corder = -1; /* XXX: None yet */ + udata.found_op = NULL; + udata.found_op_data = NULL; + + /* Remove the record from the name index v2 B-tree */ + if(H5B2_remove(f, dxpl_id, H5A_BT2_NAME, oh->name_bt2_addr, &udata, H5A_dense_remove_bt2_cb, &udata) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from name index v2 B-tree") + +done: + /* Release resources */ + if(fheap && H5HF_close(fheap, dxpl_id) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5A_dense_remove() */ + + +/*------------------------------------------------------------------------- * Function: H5A_dense_delete * * Purpose: Delete all dense storage structures for attributes on an object @@ -792,7 +1198,7 @@ H5A_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh) HDassert(oh); /* XXX: iterate through name index v2 B-tree and delete shared attributes */ -/* XXX: we need to delete attributes that use shared & committed components also */ +/* XXX: we need to delete shared/unshared attributes that use shared & committed components also */ /* Delete name index v2 B-tree */ if(H5B2_delete(f, dxpl_id, H5A_BT2_NAME, oh->name_bt2_addr, NULL, NULL) < 0) diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 22ca0e3..dc5f65a 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -31,6 +31,7 @@ /****************/ #define H5A_PACKAGE /*suppress error about including H5Apkg */ +#define H5O_PACKAGE /*suppress error about including H5Opkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5A_init_deprec_interface @@ -44,6 +45,7 @@ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ /****************/ @@ -155,7 +157,7 @@ H5Aget_num_attrs(hid_t loc_id) } /*lint !e788 All appropriate cases are covered */ /* Look up the # of attributes for the object */ - if((ret_value = H5O_msg_count(loc, H5O_ATTR_ID, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5O_attr_count(loc, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "can't get attribute count for object") done: diff --git a/src/H5Apkg.h b/src/H5Apkg.h index 754c215..85be22e 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -114,6 +114,29 @@ typedef struct H5A_bt2_ud_ins_t { uint8_t id[H5A_DENSE_FHEAP_ID_LEN]; /* Heap ID of attribute to insert */ } H5A_bt2_ud_ins_t; +/* Data structure to hold table of attributes for an object */ +typedef struct { + size_t nattrs; /* # of attributes in table */ + H5A_t *attrs; /* Pointer to array of attributes */ + uint8_t *flags; /* Pointer to array of message flags for attributes */ +} H5A_attr_table_t; + +/* Attribute iteration operator for internal library callbacks */ +typedef herr_t (*H5A_lib_iterate_t)(const H5A_t *attr, uint8_t mesg_flags, + void *op_data); + +/* Describe kind of callback to make for each attribute */ +typedef struct { + enum { + H5A_ATTR_OP_APP, /* Application callback */ + H5A_ATTR_OP_LIB /* Library internal callback */ + } op_type; + union { + H5A_operator_t app_op; /* Application callback for each attribute */ + H5A_lib_iterate_t lib_op; /* Library internal callback for each attribute */ + } u; +} H5A_attr_iterate_t; + /*****************************/ /* Package Private Variables */ @@ -146,10 +169,18 @@ H5_DLL herr_t H5A_dense_write(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, const H5A_t *attr); H5_DLL herr_t H5A_dense_iterate(H5F_t *f, hid_t dxpl_id, hid_t loc_id, haddr_t attr_fheap_addr, haddr_t name_bt2_addr, unsigned skip, - unsigned *last_attr, H5A_operator_t op, void *op_data); + unsigned *last_attr, const H5A_attr_iterate_t *attr_op, void *op_data); +H5_DLL herr_t H5A_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, + const char *name); + +/* Attribute table operations */ +H5_DLL herr_t H5A_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, + H5_index_t idx_type, H5_iter_order_t order, H5A_attr_table_t *atable); +H5_DLL herr_t H5A_attr_release_table(H5A_attr_table_t *atable); /* Attribute object header routines */ H5_DLL herr_t H5O_attr_reset(void *_mesg); +H5_DLL herr_t H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link); H5_DLL herr_t H5O_attr_get_share(const void *_mesg, H5O_shared_t *sh); #endif /* _H5Apkg_H */ @@ -656,7 +656,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5L_index_t idx_type, +H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info, hid_t lapl_id) { H5G_loc_t loc; /* Location of group */ @@ -673,7 +673,7 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5L_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5L_INDEX_UNKNOWN || idx_type >= H5L_INDEX_N) + if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index b33f7d1..3a6d5a1 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -63,7 +63,7 @@ typedef struct { /* PRIVATE PROTOTYPES */ static herr_t H5G_compact_build_table_cb(const void *_mesg, unsigned idx, void *_udata); static herr_t H5G_compact_build_table(const H5O_loc_t *oloc, hid_t dxpl_id, - const H5O_linfo_t *linfo, H5L_index_t idx_type, H5_iter_order_t order, + const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, H5G_link_table_t *ltable); @@ -123,7 +123,7 @@ done: */ static herr_t H5G_compact_build_table(const H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5L_index_t idx_type, H5_iter_order_t order, H5G_link_table_t *ltable) + H5_index_t idx_type, H5_iter_order_t order, H5G_link_table_t *ltable) { herr_t ret_value = SUCCEED; /* Return value */ @@ -217,7 +217,7 @@ done: */ ssize_t H5G_compact_get_name_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, - const H5O_linfo_t *linfo, H5L_index_t idx_type, H5_iter_order_t order, + const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, char* name, size_t size) { H5G_link_table_t ltable = {0, NULL}; /* Link table */ @@ -281,7 +281,7 @@ H5G_compact_get_type_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *l HDassert(oloc); /* Build table of all link messages */ - if(H5G_compact_build_table(oloc, dxpl_id, linfo, H5L_INDEX_NAME, H5_ITER_INC, <able) < 0) + if(H5G_compact_build_table(oloc, dxpl_id, linfo, H5_INDEX_NAME, H5_ITER_INC, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN, "can't create link message table") /* Check for going out of bounds */ @@ -416,7 +416,7 @@ done: */ herr_t H5G_compact_remove_by_idx(const H5O_loc_t *oloc, hid_t dxpl_id, - const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, H5L_index_t idx_type, + const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, H5_index_t idx_type, H5_iter_order_t order, hsize_t n) { H5G_link_table_t ltable = {0, NULL};/* Link table */ @@ -469,7 +469,7 @@ done: */ herr_t H5G_compact_iterate(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, + H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, hid_t gid, H5G_link_iterate_t *lnk_op, void *op_data) { H5G_link_table_t ltable = {0, NULL}; /* Link table */ @@ -606,7 +606,7 @@ done: */ herr_t H5G_compact_lookup_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) { H5G_link_table_t ltable = {0, NULL};/* Link table */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Gdense.c b/src/H5Gdense.c index 86f8353..b0924ba 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -91,7 +91,7 @@ typedef struct { hid_t gid; /* Group ID for application callback */ hsize_t skip; /* Number of links to skip */ hsize_t *last_lnk; /* Pointer to the last link operated on */ - H5G_link_iterate_t *lnk_op; /* Callback for each link */ + const H5G_link_iterate_t *lnk_op; /* Callback for each link */ void *op_data; /* Callback data for each link */ /* upward */ @@ -131,7 +131,7 @@ typedef struct { * H5HF_op function when removing a link from densely stored links. */ typedef struct { - /* downward (internal) */ + /* downward */ H5F_t *f; /* Pointer to file that fractal heap is in */ hid_t dxpl_id; /* DXPL for operation */ hbool_t adj_link; /* Whether to adjust link count on object */ @@ -150,7 +150,7 @@ typedef struct { H5F_t *f; /* Pointer to file that fractal heap is in */ hid_t dxpl_id; /* DXPL for operation */ H5HF_t *fheap; /* Fractal heap handle */ - H5L_index_t idx_type; /* Primary index for removing link */ + H5_index_t idx_type; /* Primary index for removing link */ haddr_t other_bt2_addr; /* Address of "other" v2 B-tree indexing link */ H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ } H5G_bt2_ud_rmbi_t; @@ -643,7 +643,7 @@ done: */ herr_t H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) { H5HF_t *fheap = NULL; /* Fractal heap handle */ H5G_link_table_t ltable = {0, NULL}; /* Table of links */ @@ -661,7 +661,7 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HDassert(lnk); /* Determine the address of the index to use */ - if(idx_type == H5L_INDEX_NAME) { + if(idx_type == H5_INDEX_NAME) { /* Check if "native" order is OK - since names are hashed, getting them * in strictly increasing or decreasing order requires building a * table and sorting it. @@ -675,7 +675,7 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, bt2_addr = HADDR_UNDEF; } /* end if */ else { - HDassert(idx_type == H5L_INDEX_CRT_ORDER); + HDassert(idx_type == H5_INDEX_CRT_ORDER); /* This address may not be defined if creation order is tracked, but * there's no index on it. If there's no v2 B-tree that indexes @@ -771,8 +771,7 @@ done: /*------------------------------------------------------------------------- * Function: H5G_dense_build_table * - * Purpose: Builds a table containing a sorted (alphabetically) list of - * links for a group + * Purpose: Builds a table containing a sorted list of links for a group * * Note: Used for building table of links in non-native iteration order * for an index @@ -787,7 +786,7 @@ done: */ herr_t H5G_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5L_index_t idx_type, H5_iter_order_t order, H5G_link_table_t *ltable) + H5_index_t idx_type, H5_iter_order_t order, H5G_link_table_t *ltable) { herr_t ret_value = SUCCEED; /* Return value */ @@ -820,7 +819,7 @@ H5G_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, lnk_op.u.lib_op = H5G_dense_build_table_cb; /* Iterate over the links in the group, building a table of the link messages */ - if(H5G_dense_iterate(f, dxpl_id, linfo, H5L_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, (hid_t)0, &lnk_op, &udata) < 0) + if(H5G_dense_iterate(f, dxpl_id, linfo, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, (hid_t)0, &lnk_op, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over links") /* Sort link table in correct iteration order */ @@ -968,8 +967,8 @@ done: */ herr_t H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, - hid_t gid, H5G_link_iterate_t *lnk_op, void *op_data) + H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, + hid_t gid, const H5G_link_iterate_t *lnk_op, void *op_data) { H5HF_t *fheap = NULL; /* Fractal heap handle */ H5G_link_table_t ltable = {0, NULL}; /* Table of links */ @@ -1148,7 +1147,7 @@ done: */ ssize_t H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name, size_t size) { H5HF_t *fheap = NULL; /* Fractal heap handle */ @@ -1166,7 +1165,7 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, HDassert(linfo); /* Determine the address of the index to use */ - if(idx_type == H5L_INDEX_NAME) { + if(idx_type == H5_INDEX_NAME) { /* Check if "native" order is OK - since names are hashed, getting them * in strictly increasing or decreasing order requires building a * table and sorting it. @@ -1180,7 +1179,7 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, bt2_addr = HADDR_UNDEF; } /* end if */ else { - HDassert(idx_type == H5L_INDEX_CRT_ORDER); + HDassert(idx_type == H5_INDEX_CRT_ORDER); /* This address may not be defined if creation order is tracked, but * there's no index on it. If there's no v2 B-tree that indexes @@ -1279,7 +1278,7 @@ H5G_dense_get_type_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, HDassert(linfo); /* Build the table of links for this group */ - if(H5G_dense_build_table(f, dxpl_id, linfo, H5L_INDEX_NAME, H5_ITER_INC, <able) < 0) + if(H5G_dense_build_table(f, dxpl_id, linfo, H5_INDEX_NAME, H5_ITER_INC, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "error building table of links") /* Check for going out of bounds */ @@ -1322,7 +1321,7 @@ done: /*------------------------------------------------------------------------- * Function: H5G_dense_remove_fh_cb * - * Purpose: Callback for fractal heap operator when removing over links + * Purpose: Callback for fractal heap operator when removing links * * Return: SUCCEED/FAIL * @@ -1336,14 +1335,14 @@ static herr_t H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata) { H5G_fh_ud_rm_t *udata = (H5G_fh_ud_rm_t *)_udata; /* User data for fractal heap 'op' callback */ - H5O_link_t *lnk; /* Pointer to link created from heap object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_link_t *lnk = NULL; /* Pointer to link created from heap object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_dense_remove_fh_cb) /* Decode link information */ if(NULL == (lnk = H5O_msg_decode(udata->f, udata->dxpl_id, H5O_LINK_ID, obj))) - HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, H5_ITER_ERROR, "can't decode link") + HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode link") /* Check for removing the link from the creation order index */ if(udata->rem_from_corder_index) { @@ -1357,7 +1356,7 @@ H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata) HDassert(H5F_addr_defined(udata->corder_bt2_addr)); if(H5B2_remove(udata->f, udata->dxpl_id, H5G_BT2_CORDER, udata->corder_bt2_addr, &bt2_udata, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, H5_ITER_ERROR, "unable to remove link from creation order index v2 B-tree") + HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "unable to remove link from creation order index v2 B-tree") } /* end if */ /* Replace open objects' names, if requested */ @@ -1366,14 +1365,15 @@ H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata) HGOTO_ERROR(H5E_SYM, H5E_CANTRENAME, FAIL, "unable to rename open objects") /* Perform the deletion action on the link */ - /* (call link message "delete" callback directly: *ick* - QAK) */ + /* (call message "delete" callback directly: *ick* - QAK) */ if(H5O_link_delete(udata->f, udata->dxpl_id, lnk, udata->adj_link) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link") +done: /* Release the space allocated for the link */ - H5O_msg_free(H5O_LINK_ID, lnk); + if(lnk) + H5O_msg_free(H5O_LINK_ID, lnk); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_dense_remove_fh_cb() */ @@ -1401,7 +1401,7 @@ H5G_dense_remove_bt2_cb(const void *_record, void *_bt2_udata) FUNC_ENTER_NOAPI_NOINIT(H5G_dense_remove_bt2_cb) - /* Set up the user data for fractalheap 'op' callback */ + /* Set up the user data for fractal heap 'op' callback */ fh_udata.f = bt2_udata->common.f; fh_udata.dxpl_id = bt2_udata->common.dxpl_id; fh_udata.adj_link = bt2_udata->adj_link; @@ -1544,7 +1544,7 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) FUNC_ENTER_NOAPI_NOINIT(H5G_dense_remove_by_idx_bt2_cb) /* Determine the index being used */ - if(bt2_udata->idx_type == H5L_INDEX_NAME) { + if(bt2_udata->idx_type == H5_INDEX_NAME) { const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; /* Set the heap ID to operate on */ @@ -1553,13 +1553,13 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) else { const H5G_dense_bt2_corder_rec_t *record = (const H5G_dense_bt2_corder_rec_t *)_record; - HDassert(bt2_udata->idx_type == H5L_INDEX_CRT_ORDER); + HDassert(bt2_udata->idx_type == H5_INDEX_CRT_ORDER); /* Set the heap ID to operate on */ heap_id = record->id; } /* end else */ - /* Set up the user data for fractalheap 'op' callback */ + /* Set up the user data for fractal heap 'op' callback */ fh_udata.f = bt2_udata->f; fh_udata.dxpl_id = bt2_udata->dxpl_id; fh_udata.lnk = NULL; @@ -1576,7 +1576,7 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) const H5B2_class_t *other_bt2_class; /* Class of "other" v2 B-tree */ /* Determine the index being used */ - if(bt2_udata->idx_type == H5L_INDEX_NAME) { + if(bt2_udata->idx_type == H5_INDEX_NAME) { /* Set the class of the "other" index */ other_bt2_class = H5G_BT2_CORDER; @@ -1584,7 +1584,7 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) other_bt2_udata.corder = fh_udata.lnk->corder; } /* end if */ else { - HDassert(bt2_udata->idx_type == H5L_INDEX_CRT_ORDER); + HDassert(bt2_udata->idx_type == H5_INDEX_CRT_ORDER); /* Set the class of the "other" index */ other_bt2_class = H5G_BT2_NAME; @@ -1644,7 +1644,7 @@ done: */ herr_t H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5RS_str_t *grp_full_path_r, H5L_index_t idx_type, H5_iter_order_t order, + H5RS_str_t *grp_full_path_r, H5_index_t idx_type, H5_iter_order_t order, hsize_t n) { H5HF_t *fheap = NULL; /* Fractal heap handle */ @@ -1662,7 +1662,7 @@ H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HDassert(linfo); /* Determine the address of the index to use */ - if(idx_type == H5L_INDEX_NAME) { + if(idx_type == H5_INDEX_NAME) { /* Check if "native" order is OK - since names are hashed, getting them * in strictly increasing or decreasing order requires building a * table and sorting it. @@ -1676,7 +1676,7 @@ H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, bt2_addr = HADDR_UNDEF; } /* end if */ else { - HDassert(idx_type == H5L_INDEX_CRT_ORDER); + HDassert(idx_type == H5_INDEX_CRT_ORDER); /* This address may not be defined if creation order is tracked, but * there's no index on it. If there's no v2 B-tree that indexes @@ -1699,7 +1699,7 @@ H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, udata.dxpl_id = dxpl_id; udata.fheap = fheap; udata.idx_type = idx_type; - udata.other_bt2_addr = idx_type == H5L_INDEX_NAME ? linfo->corder_bt2_addr : linfo->name_bt2_addr; + udata.other_bt2_addr = idx_type == H5_INDEX_NAME ? linfo->corder_bt2_addr : linfo->name_bt2_addr; udata.grp_full_path_r = grp_full_path_r; /* Remove the record from the name index v2 B-tree */ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 6ffc3f4..9cb5abd 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -485,7 +485,7 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a group") /* Call internal function */ - if((ret_value = H5G_obj_get_name_by_idx(loc.oloc, H5L_INDEX_NAME, H5_ITER_INC, idx, name, size, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_obj_get_name_by_idx(loc.oloc, H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "can't get object name") done: @@ -746,7 +746,7 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, lnk_op.u.old_op = op; /* Call private function. */ - if((ret_value = H5G_obj_iterate(loc_id, name, H5L_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_obj_iterate(loc_id, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed") /* Set the index we stopped at */ diff --git a/src/H5Glink.c b/src/H5Glink.c index 3aa7eb4..b5c287d 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -581,7 +581,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_link_sort_table(H5G_link_table_t *ltable, H5L_index_t idx_type, +H5G_link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, H5_iter_order_t order) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_link_sort_table) @@ -590,7 +590,7 @@ H5G_link_sort_table(H5G_link_table_t *ltable, H5L_index_t idx_type, HDassert(ltable); /* Pick appropriate sorting routine */ - if(idx_type == H5L_INDEX_NAME) { + if(idx_type == H5_INDEX_NAME) { if(order == H5_ITER_INC) HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_name_inc); else if(order == H5_ITER_DEC) @@ -599,7 +599,7 @@ H5G_link_sort_table(H5G_link_table_t *ltable, H5L_index_t idx_type, HDassert(order == H5_ITER_NATIVE); } /* end if */ else { - HDassert(idx_type == H5L_INDEX_CRT_ORDER); + HDassert(idx_type == H5_INDEX_CRT_ORDER); if(order == H5_ITER_INC) HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_corder_inc); else if(order == H5_ITER_DEC) @@ -628,7 +628,7 @@ H5G_link_sort_table(H5G_link_table_t *ltable, H5L_index_t idx_type, */ herr_t H5G_link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip, - hsize_t *last_lnk, hid_t gid, H5G_link_iterate_t *lnk_op, void *op_data) + hsize_t *last_lnk, hid_t gid, const H5G_link_iterate_t *lnk_op, void *op_data) { size_t u; /* Local index variable */ herr_t ret_value = H5_ITER_CONT; /* Return value */ diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 8ba4c3e..0d54cdb 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -60,7 +60,7 @@ typedef struct { /* downward */ hid_t lapl_id; /* LAPL to use for operation */ hid_t dxpl_id; /* DXPL to use for operation */ - H5L_index_t idx_type; /* Index to use */ + H5_index_t idx_type; /* Index to use */ H5_iter_order_t order; /* Iteration order within index */ hsize_t n; /* Offset within index */ @@ -482,7 +482,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_loc_find_by_idx(H5G_loc_t *loc, const char *group_name, H5L_index_t idx_type, +H5G_loc_find_by_idx(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_loc_t *obj_loc/*out*/, hid_t lapl_id, hid_t dxpl_id) { diff --git a/src/H5Gname.c b/src/H5Gname.c index 1e1cf16..fca9320 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -1137,7 +1137,7 @@ H5G_refname_iterator(hid_t group, const char *name, const H5L_info_t *link_info, lnk_op.op_type = H5G_LINK_OP_APP; lnk_op.u.app_op = H5G_refname_iterator; - ret_value = H5G_obj_iterate(udata->file, udata->container, H5L_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, &last_obj, &lnk_op, udata, udata->dxpl_id); + ret_value = H5G_obj_iterate(udata->file, udata->container, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, &last_obj, &lnk_op, udata, udata->dxpl_id); /* If we didn't find the object, truncate the name to not include group name anymore */ if(!ret_value) diff --git a/src/H5Gobj.c b/src/H5Gobj.c index bf656e5..b7075ec 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -581,7 +581,7 @@ done: */ herr_t H5G_obj_iterate(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, + H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_link_iterate_t *lnk_op, void *op_data, hid_t dxpl_id) { H5O_linfo_t linfo; /* Link info message */ @@ -612,7 +612,7 @@ H5G_obj_iterate(hid_t loc_id, const char *group_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5L_INDEX_CRT_ORDER) { + if(idx_type == H5_INDEX_CRT_ORDER) { H5O_ginfo_t ginfo; /* Group info message */ /* Get group info message, to see if creation order is tracked for links in this group */ @@ -640,7 +640,7 @@ H5G_obj_iterate(hid_t loc_id, const char *group_name, H5E_clear_stack(NULL); /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5L_INDEX_NAME) + if(idx_type != H5_INDEX_NAME) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Iterate over symbol table */ @@ -728,7 +728,7 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5L_index_t idx_type, +H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char* name, size_t size, hid_t dxpl_id) { H5O_linfo_t linfo; /* Link info message */ @@ -742,7 +742,7 @@ H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5L_index_t idx_type, /* Attempt to get the link info for this group */ if(H5O_msg_read(oloc, H5O_LINFO_ID, 0, &linfo, dxpl_id)) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5L_INDEX_CRT_ORDER) { + if(idx_type == H5_INDEX_CRT_ORDER) { H5O_ginfo_t ginfo; /* Group info message */ /* Get group info message, to see if creation order is tracked for links in this group */ @@ -771,7 +771,7 @@ H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5L_index_t idx_type, H5E_clear_stack(NULL); /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5L_INDEX_NAME) + if(idx_type != H5_INDEX_NAME) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Get the object's name from the symbol table */ @@ -891,7 +891,7 @@ H5G_obj_remove_update_linfo(H5O_loc_t *oloc, H5O_linfo_t *linfo, hid_t dxpl_id) size_t u; /* Local index */ /* Build the table of links for this group */ - if(H5G_dense_build_table(oloc->file, dxpl_id, linfo, H5L_INDEX_NAME, H5_ITER_NATIVE, <able) < 0) + if(H5G_dense_build_table(oloc->file, dxpl_id, linfo, H5_INDEX_NAME, H5_ITER_NATIVE, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over links") /* Inspect links in table for ones that can't be converted back @@ -1004,10 +1004,9 @@ H5G_obj_remove(H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name, h } /* end else */ /* Update link info for a new-style group */ - if(!use_old_format) { + if(!use_old_format) if(H5G_obj_remove_update_linfo(oloc, &linfo, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUPDATE, FAIL, "unable to update link info") - } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -1029,7 +1028,7 @@ done: */ herr_t H5G_obj_remove_by_idx(H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t dxpl_id) + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t dxpl_id) { H5O_linfo_t linfo; /* Link info message */ hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for deletion or not */ @@ -1043,7 +1042,7 @@ H5G_obj_remove_by_idx(H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, /* Attempt to get the link info for this group */ if(H5O_msg_read(grp_oloc, H5O_LINFO_ID, 0, &linfo, dxpl_id)) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5L_INDEX_CRT_ORDER) { + if(idx_type == H5_INDEX_CRT_ORDER) { H5O_ginfo_t ginfo; /* Group info message */ /* Get group info message, to see if creation order is tracked for links in this group */ @@ -1075,7 +1074,7 @@ H5G_obj_remove_by_idx(H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, H5E_clear_stack(NULL); /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5L_INDEX_NAME) + if(idx_type != H5_INDEX_NAME) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Using the old format for groups */ @@ -1166,7 +1165,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_obj_lookup_by_idx(H5O_loc_t *grp_oloc, H5L_index_t idx_type, +H5G_obj_lookup_by_idx(H5O_loc_t *grp_oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk, hid_t dxpl_id) { H5O_linfo_t linfo; /* Link info message */ @@ -1180,7 +1179,7 @@ H5G_obj_lookup_by_idx(H5O_loc_t *grp_oloc, H5L_index_t idx_type, /* Attempt to get the link info message for this group */ if(H5O_msg_read(grp_oloc, H5O_LINFO_ID, 0, &linfo, dxpl_id)) { /* Check for creation order tracking, if creation order index lookup requested */ - if(idx_type == H5L_INDEX_CRT_ORDER) { + if(idx_type == H5_INDEX_CRT_ORDER) { H5O_ginfo_t ginfo; /* Group info message */ /* Get group info message, to see if creation order is tracked for links in this group */ @@ -1209,7 +1208,7 @@ H5G_obj_lookup_by_idx(H5O_loc_t *grp_oloc, H5L_index_t idx_type, H5E_clear_stack(NULL); /* Can only perform name lookups on groups with symbol tables */ - if(idx_type != H5L_INDEX_NAME) + if(idx_type != H5_INDEX_NAME) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no creation order index to query") /* Get the object's info from the symbol table */ diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index c5949b1..fbf1b44 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -442,10 +442,10 @@ H5_DLL herr_t H5G_link_to_loc(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, H5_DLL herr_t H5G_link_copy_file(H5F_t *dst_file, hid_t dxpl_id, const H5O_link_t *_src_lnk, const H5O_loc_t *src_oloc, H5O_link_t *dst_lnk, H5O_copy_t *cpy_info); -H5_DLL herr_t H5G_link_sort_table(H5G_link_table_t *ltable, H5L_index_t idx_type, +H5_DLL herr_t H5G_link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, H5_iter_order_t order); H5_DLL herr_t H5G_link_iterate_table(const H5G_link_table_t *ltable, - hsize_t skip, hsize_t *last_lnk, hid_t gid, H5G_link_iterate_t *lnk_op, + hsize_t skip, hsize_t *last_lnk, hid_t gid, const H5G_link_iterate_t *lnk_op, void *op_data); H5_DLL herr_t H5G_link_release_table(H5G_link_table_t *ltable); H5_DLL herr_t H5G_link_name_replace(H5F_t *file, hid_t dxpl_id, @@ -456,47 +456,47 @@ H5_DLL herr_t H5G_link_name_replace(H5F_t *file, hid_t dxpl_id, H5_DLL herr_t H5G_compact_insert(H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk, hid_t dxpl_id); H5_DLL ssize_t H5G_compact_get_name_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, - const H5O_linfo_t *linfo, H5L_index_t idx_type, H5_iter_order_t order, + const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, char *name, size_t size); H5_DLL H5G_obj_t H5G_compact_get_type_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, hsize_t idx); H5_DLL herr_t H5G_compact_remove(const H5O_loc_t *oloc, hid_t dxpl_id, H5RS_str_t *grp_full_path_r, const char *name); H5_DLL herr_t H5G_compact_remove_by_idx(const H5O_loc_t *oloc, hid_t dxpl_id, - const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, H5L_index_t idx_type, + const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, H5_index_t idx_type, H5_iter_order_t order, hsize_t n); H5_DLL herr_t H5G_compact_iterate(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, + H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, hid_t gid, H5G_link_iterate_t *lnk_op, void *op_data); H5_DLL herr_t H5G_compact_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, hid_t dxpl_id); H5_DLL herr_t H5G_compact_lookup_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, - const H5O_linfo_t *linfo, H5L_index_t idx_type, H5_iter_order_t order, + const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk); /* Functions that understand "dense" link storage */ H5_DLL herr_t H5G_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5L_index_t idx_type, H5_iter_order_t order, H5G_link_table_t *ltable); + H5_index_t idx_type, H5_iter_order_t order, H5G_link_table_t *ltable); H5_DLL herr_t H5G_dense_create(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo); H5_DLL herr_t H5G_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, const H5O_link_t *lnk); H5_DLL herr_t H5G_dense_lookup(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, const char *name, H5O_link_t *lnk); H5_DLL herr_t H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, - const H5O_linfo_t *linfo, H5L_index_t idx_type, H5_iter_order_t order, + const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk); H5_DLL herr_t H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, - hid_t gid, H5G_link_iterate_t *lnk_op, void *op_data); + H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, + hid_t gid, const H5G_link_iterate_t *lnk_op, void *op_data); H5_DLL ssize_t H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, - H5O_linfo_t *linfo, H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name, size_t size); H5_DLL H5G_obj_t H5G_dense_get_type_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hsize_t idx); H5_DLL herr_t H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, const char *name); H5_DLL herr_t H5G_dense_remove_by_idx(H5F_t *f, hid_t dxpl_id, - const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, H5L_index_t idx_type, + const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, H5_index_t idx_type, H5_iter_order_t order, hsize_t n); H5_DLL herr_t H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link); @@ -507,20 +507,20 @@ H5_DLL herr_t H5G_obj_create(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, H5_DLL herr_t H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, hbool_t adj_link, hid_t dxpl_id); H5_DLL herr_t H5G_obj_iterate(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_obj, + H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_obj, H5G_link_iterate_t *lnk_op, void *op_data, hid_t dxpl_id); H5_DLL herr_t H5G_obj_info(H5O_loc_t *oloc, H5G_info_t *grp_info, hid_t dxpl_id); -H5_DLL ssize_t H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5L_index_t idx_type, +H5_DLL ssize_t H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char* name, size_t size, hid_t dxpl_id); H5_DLL H5G_obj_t H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id); H5_DLL herr_t H5G_obj_remove(H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name, hid_t dxpl_id); H5_DLL herr_t H5G_obj_remove_by_idx(H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t dxpl_id); + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t dxpl_id); H5_DLL herr_t H5G_obj_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, hid_t dxpl_id); -H5_DLL herr_t H5G_obj_lookup_by_idx(H5O_loc_t *grp_oloc, H5L_index_t idx_type, +H5_DLL herr_t H5G_obj_lookup_by_idx(H5O_loc_t *grp_oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk, hid_t dxpl_id); /* diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index d5350f9..2b444cf 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -194,7 +194,7 @@ H5_DLL herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc); H5_DLL herr_t H5G_loc_find(H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc/*out*/, hid_t lapl_id, hid_t dxpl_id); H5_DLL herr_t H5G_loc_find_by_idx(H5G_loc_t *loc, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_loc_t *obj_loc/*out*/, hid_t lapl_id, hid_t dxpl_id); H5_DLL herr_t H5G_loc_info(H5G_loc_t *loc, const char *name, H5O_info_t *oinfo/*out*/, hid_t lapl_id, hid_t dxpl_id); diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 61c419a..56f3d77 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -128,7 +128,7 @@ H5_DLL hid_t H5Gget_create_plist(hid_t group_id); H5_DLL herr_t H5Gget_info(hid_t loc_id, const char *name, H5G_info_t *ginfo, hid_t lapl_id); H5_DLL herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *ginfo, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *ginfo, hid_t lapl_id); H5_DLL herr_t H5Gclose(hid_t group_id); diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 3310024..6079427 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -494,7 +494,7 @@ H5G_stab_iterate(H5O_loc_t *oloc, hid_t dxpl_id, H5_iter_order_t order, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") /* Sort link table in correct iteration order */ - if(H5G_link_sort_table(<able, H5L_INDEX_NAME, order) < 0) + if(H5G_link_sort_table(<able, H5_INDEX_NAME, order) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting link messages") /* Iterate over links in table */ @@ -57,7 +57,7 @@ typedef struct { /* User data for path traversal routine for getting link info by index */ typedef struct { /* In */ - H5L_index_t idx_type; /* Index to use */ + H5_index_t idx_type; /* Index to use */ H5_iter_order_t order; /* Order to iterate in index */ hsize_t n; /* Offset of link within index */ hid_t dxpl_id; /* DXPL to use in callback */ @@ -102,7 +102,7 @@ typedef struct { /* User data for path traversal routine for getting link value by index */ typedef struct { /* In */ - H5L_index_t idx_type; /* Index to use */ + H5_index_t idx_type; /* Index to use */ H5_iter_order_t order; /* Order to iterate in index */ hsize_t n; /* Offset of link within index */ hid_t dxpl_id; /* DXPL to use in callback */ @@ -120,7 +120,7 @@ typedef struct { /* User data for path traversal routine for removing link by index */ typedef struct { /* In */ - H5L_index_t idx_type; /* Index to use */ + H5_index_t idx_type; /* Index to use */ H5_iter_order_t order; /* Order to iterate in index */ hsize_t n; /* Offset of link within index */ hid_t dxpl_id; /* DXPL to use in callback */ @@ -129,7 +129,7 @@ typedef struct { /* User data for path traversal routine for getting name by index */ typedef struct { /* In */ - H5L_index_t idx_type; /* Index to use */ + H5_index_t idx_type; /* Index to use */ H5_iter_order_t order; /* Order to iterate in index */ hsize_t n; /* Offset of link within index */ size_t size; /* Size of name buffer */ @@ -158,7 +158,7 @@ static herr_t H5L_get_val_by_idx_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); static herr_t H5L_get_val_by_idx(H5G_loc_t *loc, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, void *buf/*out*/, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, void *buf/*out*/, size_t size, hid_t lapl_id, hid_t dxpl_id); static herr_t H5L_delete_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, @@ -167,7 +167,7 @@ static herr_t H5L_delete_by_idx_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); static herr_t H5L_delete_by_idx(H5G_loc_t *loc, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id, hid_t dxpl_id); static herr_t H5L_move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, @@ -182,13 +182,13 @@ static herr_t H5L_get_info_by_idx_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); static herr_t H5L_get_info_by_idx(const H5G_loc_t *loc, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5L_info_t *linkbuf/*out*/, hid_t lapl_id, hid_t dxpl_id); static herr_t H5L_get_name_by_idx_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); static herr_t H5L_get_name_by_idx(const H5G_loc_t *loc, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name/*out*/, size_t size, hid_t lapl_id, hid_t dxpl_id); /*********************/ @@ -689,7 +689,7 @@ done: */ herr_t H5Ldelete_by_idx(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { H5G_loc_t loc; /* Group's location */ herr_t ret_value = SUCCEED; /* Return value */ @@ -702,7 +702,7 @@ H5Ldelete_by_idx(hid_t loc_id, const char *group_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5L_INDEX_UNKNOWN || idx_type >= H5L_INDEX_N) + if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") @@ -789,7 +789,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5L_index_t idx_type, +H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, void *buf/*out*/, size_t size, hid_t lapl_id) { @@ -805,7 +805,7 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5L_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5L_INDEX_UNKNOWN || idx_type >= H5L_INDEX_N) + if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") @@ -884,7 +884,7 @@ done: */ herr_t H5Lget_info_by_idx(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5L_info_t *linkbuf /*out*/, hid_t lapl_id) { H5G_loc_t loc; /* Group location for group to query */ @@ -899,7 +899,7 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5L_INDEX_UNKNOWN || idx_type >= H5L_INDEX_N) + if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") @@ -1063,7 +1063,7 @@ done: */ ssize_t H5Lget_name_by_idx(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id) { H5G_loc_t loc; /* Location of group */ @@ -1078,7 +1078,7 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5L_INDEX_UNKNOWN || idx_type >= H5L_INDEX_N) + if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") @@ -1121,7 +1121,7 @@ done: */ herr_t H5Literate(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate_t op, void *op_data, hid_t lapl_id) { H5G_link_iterate_t lnk_op; /* Link operator */ @@ -1136,7 +1136,7 @@ H5Literate(hid_t loc_id, const char *group_name, /* Check arguments */ if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5L_INDEX_UNKNOWN || idx_type >= H5L_INDEX_N) + if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") @@ -1988,7 +1988,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L_get_val_by_idx(H5G_loc_t *loc, const char *group_name, H5L_index_t idx_type, +H5L_get_val_by_idx(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, void *buf/*out*/, size_t size, hid_t lapl_id, hid_t dxpl_id) { @@ -2163,7 +2163,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L_delete_by_idx(H5G_loc_t *loc, const char *group_name, H5L_index_t idx_type, +H5L_delete_by_idx(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id, hid_t dxpl_id) { H5L_trav_rmbi_t udata; /* User data for callback */ @@ -2664,7 +2664,7 @@ done: */ static herr_t H5L_get_info_by_idx(const H5G_loc_t *loc, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5L_info_t *linkbuf/*out*/, hid_t lapl_id, hid_t dxpl_id) { H5L_trav_gibi_t udata; /* User data for callback */ @@ -2776,7 +2776,7 @@ done: */ static herr_t H5L_get_name_by_idx(const H5G_loc_t *loc, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name/*out*/, size_t size, hid_t lapl_id, hid_t dxpl_id) { H5L_trav_gnbi_t udata; /* User data for callback */ diff --git a/src/H5Lpublic.h b/src/H5Lpublic.h index 03ec81e..42f5667 100644 --- a/src/H5Lpublic.h +++ b/src/H5Lpublic.h @@ -120,17 +120,6 @@ typedef struct { H5L_query_func_t query_func; /* Callback for queries */ } H5L_class_t; -/* - * The types of indices on links in groups. Primarily used for "<do> <foo> by - * index" routines and for iterating over links in groups. - */ -typedef enum H5L_index_t { - H5L_INDEX_UNKNOWN = -1, /* Unknown index type */ - H5L_INDEX_NAME, /* Index on names of links */ - H5L_INDEX_CRT_ORDER, /* Index on creation order of links */ - H5L_INDEX_N /* Number of indices defined on links in groups */ -} H5L_index_t; - /* Prototype for H5Literate() operator */ typedef herr_t (*H5L_iterate_t)(hid_t group, const char *name, const H5L_info_t *info, void *op_data); @@ -157,22 +146,22 @@ H5_DLL herr_t H5Lcreate_soft(const char *target_path, hid_t cur_loc, const char *cur_name, hid_t lcpl_id, hid_t lapl_id); H5_DLL herr_t H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id); H5_DLL herr_t H5Ldelete_by_idx(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id); + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id); H5_DLL herr_t H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, hid_t lapl_id); H5_DLL herr_t H5Lget_val_by_idx(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, void *buf/*out*/, size_t size, hid_t lapl_id); H5_DLL herr_t H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linkbuf /*out*/, hid_t lapl_id); H5_DLL herr_t H5Lget_info_by_idx(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5L_info_t *linkbuf /*out*/, hid_t lapl_id); H5_DLL ssize_t H5Lget_name_by_idx(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id); H5_DLL herr_t H5Literate(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t *idx, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data, hid_t lapl_id); /* UD link functions */ @@ -229,7 +229,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5L_index_t idx_type, +H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { H5G_loc_t loc; @@ -247,7 +247,7 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5L_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5L_INDEX_UNKNOWN || idx_type >= H5L_INDEX_N) + if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") @@ -496,7 +496,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5L_index_t idx_type, +H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, hid_t lapl_id) { H5G_loc_t loc; /* Location of group */ @@ -513,7 +513,7 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5L_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_type <= H5L_INDEX_UNKNOWN || idx_type >= H5L_INDEX_N) + if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 5c1aba8..59a684e 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -33,7 +33,6 @@ static void *H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p); static void *H5O_attr_copy(const void *_mesg, void *_dest); static size_t H5O_attr_size(const H5F_t *f, const void *_mesg); static herr_t H5O_attr_free(void *mesg); -static herr_t H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link); static herr_t H5O_attr_link(H5F_t *f, hid_t dxpl_id, const void *_mesg); static herr_t H5O_attr_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type, const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata); @@ -647,7 +646,7 @@ H5O_attr_free(void *mesg) * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link) { const H5A_t *attr = (const H5A_t *) _mesg; @@ -672,9 +671,9 @@ H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message from datatype") if(H5SM_try_delete(f, H5AC_dxpl_id, H5O_DTYPE_ID, &sh_mesg) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTREMOVE, FAIL, "can't remove datatype from SOHM heap") - } + } /* end if */ - if((tri_ret =H5O_msg_is_shared(H5O_SDSPACE_ID, attr->ds)) < 0) + if((tri_ret = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->ds)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't tell if dataspace is shared") if(tri_ret > 0) { @@ -682,7 +681,7 @@ H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message from dataspace") if(H5SM_try_delete(f, H5AC_dxpl_id, H5O_SDSPACE_ID, &sh_mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_SOHM, FAIL, "can't remove dataspace from SOHM heap") - } + } /* end if */ /* Check whether datatype is shared */ if(H5T_committed(attr->dt)) { diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index 3c440b6..7d22319 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -104,6 +104,17 @@ typedef struct { unsigned count; /* Count of attributes examined */ } H5O_iter_itr_t; +/* User data for iteration when removing an attribute */ +typedef struct { + /* down */ + H5F_t *f; /* Pointer to file attribute is in */ + hid_t dxpl_id; /* DXPL for operation */ + const char *name; /* Name of attribute to open */ + + /* up */ + hbool_t found; /* Found attribute to delete */ +} H5O_iter_rm_t; + /********************/ /* Package Typedefs */ @@ -236,6 +247,7 @@ HDfprintf(stderr, "%s: converting attributes to dense storage\n", FUNC); udata.dxpl_id = dxpl_id; /* Iterate over existing attributes, moving them to dense storage */ +/* XXX: Test this with shared attributes */ op.lib_op = H5A_attr_to_dense_cb; if(H5O_msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, TRUE, op, &udata, dxpl_id, &oh_flags) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCONVERT, FAIL, "error converting attributes to dense storage") @@ -378,6 +390,7 @@ HDfprintf(stderr, "%s: oh->min_dense = %u\n", FUNC, oh->min_dense); #endif /* QAK */ /* Check for opening attribute with dense storage */ if(H5F_addr_defined(oh->attr_fheap_addr)) { +/* XXX: Need to support/test shared attributes in dense storage */ /* Open attribute in dense storage */ if(NULL == (ret_value = H5A_dense_open(loc->file, dxpl_id, oh, name))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") @@ -392,10 +405,10 @@ HDfprintf(stderr, "%s: oh->min_dense = %u\n", FUNC, oh->min_dense); udata.name = name; udata.attr = NULL; - /* Iterate over attributes, to locate correct one to update */ + /* Iterate over attributes, to locate correct one to open */ op.lib_op = H5O_attr_open_cb; if(H5O_msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, TRUE, op, &udata, dxpl_id, &oh_flags) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, NULL, "error updating attribute") + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "error updating attribute") /* Check that we found the attribute */ if(!udata.attr) @@ -839,13 +852,19 @@ H5O_attr_iterate(hid_t loc_id, const H5O_loc_t *loc, hid_t dxpl_id, /* Release the object header */ if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_ATTR, H5E_PROTECT, FAIL, "unable to release object header") + HGOTO_ERROR(H5E_ATTR, H5E_PROTECT, FAIL, "unable to release object header") oh = NULL; /* Check for attributes stored densely */ if(H5F_addr_defined(attr_fheap_addr)) { + H5A_attr_iterate_t attr_op; /* Attribute operator */ + + /* Build attribute operator info */ + attr_op.op_type = H5A_ATTR_OP_APP; + attr_op.u.app_op = op; + if((ret_value = H5A_dense_iterate(loc->file, dxpl_id, loc_id, attr_fheap_addr, - name_bt2_addr, skip, last_attr, op, op_data)) < 0) + name_bt2_addr, skip, last_attr, &attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); } /* end if */ else { @@ -890,3 +909,245 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_attr_iterate */ + +/*------------------------------------------------------------------------- + * Function: H5O_attr_remove_cb + * + * Purpose: Object header iterator callback routine to remove an + * attribute stored compactly. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 11 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, + unsigned UNUSED sequence, unsigned *oh_flags_ptr, void *_udata/*in,out*/) +{ + H5O_iter_rm_t *udata = (H5O_iter_rm_t *)_udata; /* Operator user data */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5O_attr_remove_cb) + + /* check args */ + HDassert(oh); + HDassert(mesg); + + /* Check for shared message */ + if(mesg->flags & H5O_MSG_FLAG_SHARED) { + H5A_t shared_attr; /* Copy of shared attribute */ + + /* + * If the message is shared then then the native pointer points to an + * H5O_MSG_SHARED message. We use that information to look up the real + * message in the global heap or some other object header. + */ + if(NULL == H5O_shared_read(udata->f, udata->dxpl_id, mesg->native, H5O_MSG_ATTR, &shared_attr)) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5_ITER_ERROR, "unable to read shared attribute") + +HDfprintf(stderr, "%s: removing a shared attribute not supported yet!\n", FUNC); +HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "deleting a shared attribute not supported yet") + /* Check for correct attribute message to modify */ + if(HDstrcmp(shared_attr.name, udata->name) == 0) + /* Indicate that this message is the attribute to be deleted */ + udata->found = TRUE; + + /* Release copy of shared attribute */ + H5O_attr_reset(&shared_attr); + } /* end if */ + else { + /* Check for correct attribute message to modify */ + if(HDstrcmp(((H5A_t *)mesg->native)->name, udata->name) == 0) + /* Indicate that this message is the attribute to be deleted */ + udata->found = TRUE; + } /* end else */ + + /* Check for finding correct message to delete */ + if(udata->found) { + /* If the later version of the object header format, decrement attribute */ + /* (must be decremented before call to H5O_release_mesg(), in order for + * sanity checks to pass - QAK) + */ + if(oh->version > H5O_VERSION_1) + oh->nattrs--; + + /* Convert message into a null message (i.e. delete it) */ + if(H5O_release_mesg(udata->f, udata->dxpl_id, oh, mesg, TRUE, TRUE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to convert into null message") + + /* Stop iterating */ + ret_value = H5_ITER_STOP; + + /* Indicate that the object header was modified */ + *oh_flags_ptr |= H5AC__DIRTIED_FLAG; + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_attr_remove_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_attr_remove + * + * Purpose: Delete an attributes on an object. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, December 11, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_attr_remove(const H5O_loc_t *loc, const char *name, hid_t dxpl_id) +{ + H5O_t *oh = NULL; /* Pointer to actual object header */ + unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Metadata cache flags for object header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5O_attr_remove) + + /* Check arguments */ + HDassert(loc); + HDassert(name); + + /* Protect the object header to iterate over */ + if(NULL == (oh = H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, FAIL, "unable to load object header") + + /* Check for attributes stored densely */ + if(H5F_addr_defined(oh->attr_fheap_addr)) { + /* Delete attribute from dense storage */ + if(H5A_dense_remove(loc->file, dxpl_id, oh, name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute in dense storage") + + /* Decrement # of attributes on object */ + oh->nattrs--; + } /* end if */ + else { + H5O_iter_rm_t udata; /* User data for callback */ + H5O_mesg_operator_t op; /* Wrapper for operator */ + + /* Set up user data for callback */ + udata.f = loc->file; + udata.dxpl_id = dxpl_id; + udata.name = name; + udata.found = FALSE; + + /* Iterate over attributes, to locate correct one to delete */ + op.lib_op = H5O_attr_remove_cb; + if(H5O_msg_iterate_real(loc->file, oh, H5O_MSG_ATTR, TRUE, op, &udata, dxpl_id, &oh_flags) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "error deleting attribute") + + /* Check that we found the attribute */ + if(!udata.found) + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't locate attribute") + } /* end else */ + + /* Check for shifting from dense storage back to compact storage */ + if(H5F_addr_defined(oh->attr_fheap_addr) && oh->nattrs < oh->min_dense) { + /* Check if there's no more attributes */ + if(oh->nattrs == 0) { +/* XXX: Test this */ + /* Delete the dense storage */ + if(H5A_dense_delete(loc->file, dxpl_id, oh) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete dense attribute storage") + } /* end if */ + else { + H5A_attr_table_t atable = {0, NULL, NULL}; /* Table of attributes */ + hbool_t can_convert = TRUE; /* Whether converting to attribute messages is possible */ + size_t u; /* Local index */ + + /* Build the table of attributes for this object */ +/* XXX: Test this with shared attributes */ + if(H5A_dense_build_table(loc->file, dxpl_id, oh, H5_INDEX_NAME, H5_ITER_NATIVE, &atable) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "error building attribute table") + + /* Inspect attributes in table for ones that can't be converted back + * into attribute message form (currently only attributes which + * can't fit into an object header message) + */ + for(u = 0; u < oh->nattrs; u++) + if(H5O_msg_mesg_size(loc->file, H5O_ATTR_ID, &(atable.attrs[u]), (size_t)0) >= H5O_MESG_MAX_SIZE) { + can_convert = FALSE; + break; + } /* end if */ + + /* If ok, insert attributes as object header messages */ + if(can_convert) { + /* Insert attribute messages into object header */ + for(u = 0; u < oh->nattrs; u++) + if(H5O_msg_append_real(loc->file, dxpl_id, oh, H5O_MSG_ATTR, (unsigned)atable.flags[u], H5O_UPDATE_TIME, &(atable.attrs[u]), &oh_flags) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't create message") + + /* Remove the dense storage */ + if(H5A_dense_delete(loc->file, dxpl_id, oh) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete dense attribute storage") + } /* end if */ + + /* Free attribute table information */ + if(H5A_attr_release_table(&atable) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "unable to release attribute table") + } /* end else */ + } /* end if */ + +done: + if(oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, oh_flags) < 0) + HDONE_ERROR(H5E_ATTR, H5E_PROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_attr_remove */ + + +/*------------------------------------------------------------------------- + * Function: H5O_attr_count + * + * Purpose: Determine the # of attributes on an object + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, December 11, 2006 + * + *------------------------------------------------------------------------- + */ +int +H5O_attr_count(const H5O_loc_t *loc, hid_t dxpl_id) +{ + H5O_t *oh = NULL; /* Pointer to actual object header */ + int ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5O_attr_count) + + /* Check arguments */ + HDassert(loc); + + /* Protect the object header to iterate over */ + if(NULL == (oh = H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_READ))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, FAIL, "unable to load object header") + + /* Check for attributes stored densely */ + if(oh->version > H5O_VERSION_1) +/* XXX: test this */ + ret_value = (int)oh->nattrs; + else { + unsigned u; /* Local index variable */ + + /* Loop over all messages, counting the attributes */ + for(u = ret_value = 0; u < oh->nmesgs; u++) + if(oh->mesg[u].type == H5O_MSG_ATTR) + ret_value++; + } /* end else */ + +done: + if(oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_ATTR, H5E_PROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_attr_count */ + diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c index 02da141..c5cede0 100644 --- a/src/H5Olinfo.c +++ b/src/H5Olinfo.c @@ -528,7 +528,7 @@ H5O_linfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, lnk_op.u.lib_op = H5O_linfo_post_copy_file_cb; /* Iterate over the links in the group, building a table of the link messages */ - if(H5G_dense_iterate(src_oloc->file, dxpl_id, linfo_src, H5L_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, (hid_t)0, &lnk_op, &udata) < 0) + if(H5G_dense_iterate(src_oloc->file, dxpl_id, linfo_src, H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)0, NULL, (hid_t)0, &lnk_op, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over links") } /* end if */ diff --git a/src/H5Omessage.c b/src/H5Omessage.c index 1dbe8ff..bfda315 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -768,7 +768,7 @@ H5O_msg_free_real(const H5O_msg_class_t *type, void *msg_native) if(msg_native) { H5O_msg_reset_real(type, msg_native); - if (NULL!=(type->free)) + if(NULL != (type->free)) (type->free)(msg_native); else H5MM_xfree(msg_native); @@ -1032,6 +1032,7 @@ H5O_msg_remove(H5O_loc_t *loc, unsigned type_id, int sequence, hbool_t adj_link, HDassert(loc); HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); + HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ HDassert(type_id < NELMTS(H5O_msg_class_g)); type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); @@ -1075,6 +1076,7 @@ H5O_msg_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence, HDassert(loc); HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); + HDassert(H5O_ATTR_ID != type_id); /* Attributes are modified in another routine */ HDassert(type_id < NELMTS(H5O_msg_class_g)); type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */ HDassert(type); @@ -1137,10 +1139,6 @@ H5O_msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, if(mesg->flags & H5O_MSG_FLAG_CONSTANT) udata->nfailed++; else { - /* If the message removed is an attribute, decrement count */ - if(H5O_ATTR_ID == mesg->type->id && oh->version > H5O_VERSION_1) - oh->nattrs--; - /* Convert message into a null message */ if(H5O_release_mesg(udata->f, udata->dxpl_id, oh, mesg, TRUE, udata->adj_link) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to convert into null message") @@ -1980,12 +1978,11 @@ H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_mesg_t *mesg, hbool_t adj_link) /* Check if this message needs to be removed from the SOHM table */ /* JAMES: there should be a callback, maybe in H5O_shared_delete, to fiddle w/ the ref. count. * We shouldn't need to do a search in the SOHM table on delete. */ - if(type == H5O_MSG_SHARED) - { + if(type == H5O_MSG_SHARED) { /* The native message here is actually a shared message. */ if(H5SM_try_delete(f, dxpl_id, mesg->type->id, mesg->native) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to delete message from SOHM table") - } + } /* end if */ if((type->del)(f, dxpl_id, mesg->native, adj_link) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message") diff --git a/src/H5Opkg.h b/src/H5Opkg.h index b4f5b15..07ccdd4 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -429,6 +429,9 @@ H5_DLL herr_t H5O_attr_rename(const H5O_loc_t *loc, hid_t dxpl_id, const char *old_name, const char *new_name); H5_DLL herr_t H5O_attr_iterate(hid_t loc_id, const H5O_loc_t *loc, hid_t dxpl_id, unsigned skip, unsigned *last_attr, H5A_operator_t op, void *op_data); +H5_DLL herr_t H5O_attr_remove(const H5O_loc_t *loc, const char *name, + hid_t dxpl_id); +H5_DLL int H5O_attr_count(const H5O_loc_t *loc, hid_t dxpl_id); /* These functions operate on object locations */ H5_DLL H5O_loc_t *H5O_get_loc(hid_t id); diff --git a/src/H5Opublic.h b/src/H5Opublic.h index 6895716..573c3ec 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -120,11 +120,11 @@ extern "C" { H5_DLL hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id); H5_DLL hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr); H5_DLL hid_t H5Oopen_by_idx(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id); + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id); H5_DLL herr_t H5Oget_info(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id); H5_DLL herr_t H5Oget_info_by_idx(hid_t loc_id, const char *group_name, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, hid_t lapl_id); H5_DLL herr_t H5Oincr_refcount(hid_t object_id); H5_DLL herr_t H5Odecr_refcount(hid_t object_id); diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 515120b..83ae330 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -236,6 +236,7 @@ H5_DLL herr_t H5Pset_sym_k(hid_t plist_id, unsigned ik, unsigned lk); H5_DLL herr_t H5Pget_sym_k(hid_t plist_id, unsigned *ik/*out*/, unsigned *lk/*out*/); H5_DLL herr_t H5Pset_istore_k(hid_t plist_id, unsigned ik); H5_DLL herr_t H5Pget_istore_k(hid_t plist_id, unsigned *ik/*out*/); +H5_DLL herr_t H5Pset_shared_mesgs(hid_t plist_id, unsigned nindexes, const unsigned mesg_type_flags[]); H5_DLL herr_t H5Pset_shared_mesg_nindexes(hid_t plist_id, unsigned nindexes); H5_DLL herr_t H5Pget_shared_mesg_nindexes(hid_t plist_id, unsigned *nindexes); H5_DLL herr_t H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_flags, unsigned min_mesg_size); diff --git a/src/H5public.h b/src/H5public.h index 2030b67..9da864c 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -264,6 +264,18 @@ typedef enum { #define H5_ITER_CONT (0) #define H5_ITER_STOP (1) +/* + * The types of indices on links in groups/attributes on objects. + * Primarily used for "<do> <foo> by index" routines and for iterating over + * links in groups/attributes on objects. + */ +typedef enum H5_index_t { + H5_INDEX_UNKNOWN = -1, /* Unknown index type */ + H5_INDEX_NAME, /* Index on names */ + H5_INDEX_CRT_ORDER, /* Index on creation order */ + H5_INDEX_N /* Number of indices defined */ +} H5_index_t; + /* Functions in H5.c */ H5_DLL herr_t H5open(void); H5_DLL herr_t H5close(void); diff --git a/src/H5trace.c b/src/H5trace.c index cb31f87..26549ad 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -895,178 +895,181 @@ H5_trace (const double *returning, const char *func, const char *type, ...) case 'I': switch (type[1]) { - case 'o': - if (ptr) { - if (vp) - fprintf (out, "0x%lx", (unsigned long)vp); - else - fprintf(out, "NULL"); - } /* end if */ - else { - H5_iter_order_t order = va_arg (ap, H5_iter_order_t); /*lint !e64 Type mismatch not really occuring */ - switch(order) { - case H5_ITER_UNKNOWN: - fprintf(out, "H5_ITER_UNKNOWN"); - break; - case H5_ITER_INC: - fprintf(out, "H5_ITER_INC"); - break; - case H5_ITER_DEC: - fprintf(out, "H5_ITER_DEC"); - break; - case H5_ITER_NATIVE: - fprintf(out, "H5_ITER_NATIVE"); - break; - case H5_ITER_N: - fprintf(out, "H5_ITER_N"); - break; - } /* end switch */ - } /* end else */ - break; - - case 's': - if (ptr) { - if (vp) { - fprintf (out, "0x%lx", (unsigned long)vp); - if (asize_idx>=0 && asize[asize_idx]>=0) { - int *p = (int*)vp; - fprintf(out, " {"); - for (i=0; i<asize[asize_idx]; i++) { - fprintf(out, "%s%d", i?", ":"", p[i]); - } - fprintf(out, "}"); - } - } else { - fprintf(out, "NULL"); - } - } else { - int is = va_arg (ap, int); - fprintf (out, "%d", is); - asize[argno] = is; - } - break; - - case 'u': - if (ptr) { - if (vp) { - fprintf (out, "0x%lx", (unsigned long)vp); - if (asize_idx>=0 && asize[asize_idx]>=0) { - unsigned *p = (unsigned*)vp; - fprintf(out, " {"); - for (i=0; i<asize[asize_idx]; i++) { - HDfprintf(out, "%s%u", i?", ":"", p[i]); - } - fprintf(out, "}"); - } - } else { - fprintf(out, "NULL"); - } - } else { - unsigned iu = va_arg (ap, unsigned); /*lint !e732 Loss of sign not really occuring */ - fprintf (out, "%u", iu); - asize[argno] = iu; - } - break; - - case 't': - if (ptr) { - if (vp) { - fprintf (out, "0x%lx", (unsigned long)vp); - } else { - fprintf(out, "NULL"); - } - } else { - H5I_type_t id_type = va_arg (ap, H5I_type_t); /*lint !e64 Type mismatch not really occuring */ - switch (id_type) { - case H5I_UNINIT: - fprintf (out, "H5I_UNINIT"); - break; - case H5I_BADID: - fprintf (out, "H5I_BADID"); - break; - case H5I_FILE: - fprintf (out, "H5I_FILE"); - break; - case H5I_GROUP: - fprintf (out, "H5I_GROUP"); - break; - case H5I_DATATYPE: - fprintf (out, "H5I_DATATYPE"); - break; - case H5I_DATASPACE: - fprintf (out, "H5I_DATASPACE"); - break; - case H5I_DATASET: - fprintf (out, "H5I_DATASET"); - break; - case H5I_ATTR: - fprintf (out, "H5I_ATTR"); - break; - case H5I_REFERENCE: - fprintf (out, "H5I_REFERENCE"); - break; - case H5I_VFL: - fprintf (out, "H5I_VFL"); - break; - case H5I_GENPROP_CLS: - fprintf (out, "H5I_GENPROP_CLS"); - break; - case H5I_GENPROP_LST: - fprintf (out, "H5I_GENPROP_LST"); - break; - case H5I_ERROR_CLASS: - fprintf (out, "H5I_ERROR_CLASS"); - break; - case H5I_ERROR_MSG: - fprintf (out, "H5I_ERROR_MSG"); - break; - case H5I_ERROR_STACK: - fprintf (out, "H5I_ERROR_STACK"); - break; - case H5I_NTYPES: - fprintf (out, "H5I_NTYPES"); - break; - default: - fprintf (out, "%ld", (long)id_type); - break; - } - } - break; - - default: - fprintf (out, "BADTYPE(I%c)", type[1]); - goto error; - } - break; - - case 'L': - switch(type[1]) { case 'i': if(ptr) { if(vp) + fprintf(out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5_index_t idx_type = va_arg(ap, H5_index_t); /*lint !e64 Type mismatch not really occuring */ + + switch(idx_type) { + case H5_INDEX_UNKNOWN: + fprintf(out, "H5_INDEX_UNKNOWN"); + break; + case H5_INDEX_NAME: + fprintf(out, "H5_INDEX_NAME"); + break; + case H5_INDEX_CRT_ORDER: + fprintf(out, "H5_INDEX_CRT_ORDER"); + break; + case H5_INDEX_N: + fprintf(out, "H5_INDEX_N"); + break; + } /* end switch */ + } /* end else */ + break; + + case 'o': + if (ptr) { + if (vp) fprintf (out, "0x%lx", (unsigned long)vp); else fprintf(out, "NULL"); + } /* end if */ + else { + H5_iter_order_t order = va_arg (ap, H5_iter_order_t); /*lint !e64 Type mismatch not really occuring */ + switch(order) { + case H5_ITER_UNKNOWN: + fprintf(out, "H5_ITER_UNKNOWN"); + break; + case H5_ITER_INC: + fprintf(out, "H5_ITER_INC"); + break; + case H5_ITER_DEC: + fprintf(out, "H5_ITER_DEC"); + break; + case H5_ITER_NATIVE: + fprintf(out, "H5_ITER_NATIVE"); + break; + case H5_ITER_N: + fprintf(out, "H5_ITER_N"); + break; + } /* end switch */ + } /* end else */ + break; + + case 's': + if (ptr) { + if (vp) { + fprintf (out, "0x%lx", (unsigned long)vp); + if (asize_idx>=0 && asize[asize_idx]>=0) { + int *p = (int*)vp; + fprintf(out, " {"); + for (i=0; i<asize[asize_idx]; i++) { + fprintf(out, "%s%d", i?", ":"", p[i]); + } + fprintf(out, "}"); + } + } else { + fprintf(out, "NULL"); + } } else { - H5L_index_t idx_type = va_arg(ap, H5L_index_t); /*lint !e64 Type mismatch not really occuring */ + int is = va_arg (ap, int); + fprintf (out, "%d", is); + asize[argno] = is; + } + break; - switch(idx_type) { - case H5L_INDEX_UNKNOWN: - fprintf(out, "H5L_INDEX_UNKNOWN"); + case 't': + if (ptr) { + if (vp) { + fprintf (out, "0x%lx", (unsigned long)vp); + } else { + fprintf(out, "NULL"); + } + } else { + H5I_type_t id_type = va_arg (ap, H5I_type_t); /*lint !e64 Type mismatch not really occuring */ + switch (id_type) { + case H5I_UNINIT: + fprintf (out, "H5I_UNINIT"); + break; + case H5I_BADID: + fprintf (out, "H5I_BADID"); + break; + case H5I_FILE: + fprintf (out, "H5I_FILE"); + break; + case H5I_GROUP: + fprintf (out, "H5I_GROUP"); + break; + case H5I_DATATYPE: + fprintf (out, "H5I_DATATYPE"); + break; + case H5I_DATASPACE: + fprintf (out, "H5I_DATASPACE"); + break; + case H5I_DATASET: + fprintf (out, "H5I_DATASET"); + break; + case H5I_ATTR: + fprintf (out, "H5I_ATTR"); + break; + case H5I_REFERENCE: + fprintf (out, "H5I_REFERENCE"); + break; + case H5I_VFL: + fprintf (out, "H5I_VFL"); + break; + case H5I_GENPROP_CLS: + fprintf (out, "H5I_GENPROP_CLS"); + break; + case H5I_GENPROP_LST: + fprintf (out, "H5I_GENPROP_LST"); + break; + case H5I_ERROR_CLASS: + fprintf (out, "H5I_ERROR_CLASS"); break; - case H5L_INDEX_NAME: - fprintf(out, "H5L_INDEX_NAME"); + case H5I_ERROR_MSG: + fprintf (out, "H5I_ERROR_MSG"); break; - case H5L_INDEX_CRT_ORDER: - fprintf(out, "H5L_INDEX_CRT_ORDER"); + case H5I_ERROR_STACK: + fprintf (out, "H5I_ERROR_STACK"); break; - case H5L_INDEX_N: - fprintf(out, "H5L_INDEX_N"); + case H5I_NTYPES: + fprintf (out, "H5I_NTYPES"); + break; + default: + fprintf (out, "%ld", (long)id_type); break; } } break; + case 'u': + if(ptr) { + if(vp) { + fprintf(out, "0x%lx", (unsigned long)vp); + if(asize_idx >= 0 && asize[asize_idx] >= 0) { + unsigned *p = (unsigned*)vp; + + fprintf(out, " {"); + for(i = 0; i < asize[asize_idx]; i++) + HDfprintf(out, "%s%u", i?", ":"", p[i]); + fprintf(out, "}"); + } /* end if */ + } /* end if */ + else + fprintf(out, "NULL"); + } /* end if */ + else { + unsigned iu = va_arg(ap, unsigned); /*lint !e732 Loss of sign not really occuring */ + + fprintf(out, "%u", iu); + asize[argno] = iu; + } /* end else */ + break; + + default: + fprintf (out, "BADTYPE(I%c)", type[1]); + goto error; + } /* end switch */ + break; + + case 'L': + switch(type[1]) { case 'l': if(ptr) { if(vp) @@ -1097,7 +1100,7 @@ H5_trace (const double *returning, const char *func, const char *type, ...) default: fprintf(out, "BADTYPE(G%c)", type[1]); goto error; - } + } /* end switch */ break; case 'M': |