From 174f0dab3fea49f4c99fedcf2c5b60902061648d Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 13 Nov 2006 11:43:29 -0500 Subject: [svn-r12896] Description: Move compact storage routines into separate file, to make room for internal routines that operate on links within group operations. Tested on: Linux/32 2.6 (chicago) --- MANIFEST | 1 + src/H5Gbtree2.c | 2 +- src/H5Gcompact.c | 668 +++++++++++++++++++++++++++++++++++++++++++++++++ src/H5Gdense.c | 21 +- src/H5Glink.c | 737 ++++++++++++------------------------------------------- src/H5Gnode.c | 13 +- src/H5Gobj.c | 198 ++------------- src/H5Gpkg.h | 30 +-- src/Makefile.am | 5 +- src/Makefile.in | 5 +- 10 files changed, 879 insertions(+), 801 deletions(-) create mode 100644 src/H5Gcompact.c diff --git a/MANIFEST b/MANIFEST index ffb8f20..40776fe 100644 --- a/MANIFEST +++ b/MANIFEST @@ -502,6 +502,7 @@ ./src/H5FSsection.c ./src/H5G.c ./src/H5Gbtree2.c +./src/H5Gcompact.c ./src/H5Gdense.c ./src/H5Gdeprec.c ./src/H5Gent.c diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index bc53998..8b0aa11 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -101,7 +101,6 @@ static herr_t H5G_dense_btree2_name_debug(FILE *stream, const H5F_t *f, hid_t dx static herr_t H5G_dense_fh_name_cmp(const void *obj, size_t obj_len, void *op_data); - /*********************/ /* Package Variables */ /*********************/ @@ -138,6 +137,7 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ /* Local Variables */ /*******************/ + /*------------------------------------------------------------------------- * Function: H5G_dense_fh_name_cmp diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c new file mode 100644 index 0000000..50e661b --- /dev/null +++ b/src/H5Gcompact.c @@ -0,0 +1,668 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Gcompact.c + * Sep 5 2005 + * Quincey Koziol + * + * Purpose: Functions for handling compact storage. + * + *------------------------------------------------------------------------- + */ +#define H5G_PACKAGE /*suppress error about including H5Gpkg */ + + +/* Packages needed by this file... */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ + +/* Private typedefs */ + +/* User data for link message iteration when building link table */ +typedef struct { + H5G_link_table_t *ltable; /* Pointer to link table to build */ + size_t curr_lnk; /* Current link to operate on */ +} H5G_compact_ud1_t; + +/* User data for deleting a link in the link messages */ +typedef struct { + /* downward */ + const char *name; /* Name to search for */ + H5F_t *file; /* File that object header is located within */ + hid_t dxpl_id; /* DXPL during insertion */ + + /* upward */ + H5G_obj_t *obj_type; /* Type of object deleted */ +} H5G_compact_ud2_t; + +/* User data for link message iteration when querying object info */ +typedef struct { + /* downward */ + const char *name; /* Name to search for */ + H5F_t *file; /* File that object header is located within */ + hid_t dxpl_id; /* DXPL during insertion */ + + /* upward */ + H5G_stat_t *statbuf; /* Stat buffer for info */ +} H5G_compact_ud3_t; + +/* User data for link message iteration when querying object location */ +typedef struct { + /* downward */ + const char *name; /* Name to search for */ + + /* upward */ + H5O_link_t *lnk; /* Link struct to fill in */ + hbool_t found; /* Flag to indicate that the object was found */ +} H5G_compact_ud4_t; + +/* User data for link message iteration when querying soft link value */ +typedef struct { + /* downward */ + const char *name; /* Name to search for */ + size_t size; /* Buffer size for link value */ + + /* upward */ + char *buf; /* Buffer to fill with link value */ +} H5G_compact_ud5_t; + +/* Private macros */ + +/* PRIVATE PROTOTYPES */ +static herr_t H5G_compact_build_table_cb(const void *_mesg, unsigned idx, void *_udata); +static herr_t H5G_compact_build_table(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); + + +/*------------------------------------------------------------------------- + * Function: H5G_compact_build_table_cb + * + * Purpose: Callback routine for searching 'link' messages for a particular + * name. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Sep 5 2005 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5G_compact_build_table_cb(const void *_mesg, unsigned UNUSED idx, void *_udata) +{ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ + H5G_compact_ud1_t *udata = (H5G_compact_ud1_t *)_udata; /* 'User data' passed in */ + herr_t ret_value=H5O_ITER_CONT; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5G_compact_build_table_cb) + + /* check arguments */ + HDassert(lnk); + HDassert(udata); + HDassert(udata->curr_lnk < udata->ltable->nlinks); + + /* Copy link message into table */ + if(NULL == H5O_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk]))) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5O_ITER_ERROR, "can't copy link message") + + /* Increment current link entry to operate on */ + udata->curr_lnk++; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_compact_build_table_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_compact_build_table + * + * Purpose: Builds a table containing a sorted (alphabetically) list of + * links for a group + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Sep 6, 2005 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5G_compact_build_table(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) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5G_compact_build_table) + + /* Sanity check */ + HDassert(oloc); + HDassert(linfo); + HDassert(ltable); + + /* Set size of table */ + H5_CHECK_OVERFLOW(linfo->nlinks, hsize_t, size_t); + ltable->nlinks = (size_t)linfo->nlinks; + + /* Allocate space for the table entries */ + if(ltable->nlinks > 0) { + H5G_compact_ud1_t udata; /* User data for iteration callback */ + + if((ltable->lnks = H5MM_malloc(sizeof(H5O_link_t) * ltable->nlinks)) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Set up user data for iteration */ + udata.ltable = ltable; + udata.curr_lnk = 0; + + /* Iterate through the link messages, adding them to the table */ + if(H5O_iterate(oloc, H5O_LINK_ID, H5G_compact_build_table_cb, &udata, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over link messages") + + /* Sort link table in correct iteration order */ + if(idx_type == H5L_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) + 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 == H5L_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 */ + } /* end if */ + else + ltable->lnks = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_compact_build_table() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_compact_insert + * + * Purpose: Insert a new symbol into the table described by GRP_ENT in + * file F. The name of the new symbol is NAME and its symbol + * table entry is OBJ_ENT. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Sep 6 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_compact_insert(H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk, + hid_t dxpl_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5G_compact_insert, FAIL) + + /* check arguments */ + HDassert(grp_oloc && grp_oloc->file); + HDassert(obj_lnk); + + /* Insert link message into group */ + if(H5O_modify(grp_oloc, H5O_LINK_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, obj_lnk, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_compact_insert() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_compact_get_name_by_idx + * + * Purpose: Returns the name of objects in the group by giving index. + * + * Return: Success: Non-negative, length of name + * Failure: Negative + * + * Programmer: Quincey Koziol + * Sep 6, 2005 + * + *------------------------------------------------------------------------- + */ +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, + hsize_t idx, char* name, size_t size) +{ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + ssize_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5G_compact_get_name_by_idx, FAIL) + + /* Sanity check */ + HDassert(oloc); + + /* Build table of all link messages */ + if(H5G_compact_build_table(oloc, dxpl_id, linfo, idx_type, order, <able) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") + + /* Check for going out of bounds */ + if(idx >= ltable.nlinks) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") + + /* Get the length of the name */ + ret_value = (ssize_t)HDstrlen(ltable.lnks[idx].name); + + /* Copy the name into the user's buffer, if given */ + if(name) { + HDstrncpy(name, ltable.lnks[idx].name, MIN((size_t)(ret_value + 1), size)); + if((size_t)ret_value >= size) + name[size - 1]='\0'; + } /* end if */ + +done: + /* Release link table */ + if(ltable.lnks) + /* Free link table information */ + if(H5G_link_release_table(<able) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_compact_get_name_by_idx() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_compact_get_type_by_idx + * + * Purpose: Returns the type of objects in the group by giving index. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Sep 12, 2005 + * + *------------------------------------------------------------------------- + */ +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) +{ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + H5G_obj_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5G_compact_get_type_by_idx, H5G_UNKNOWN) + + /* Sanity check */ + 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) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN, "can't create link message table") + + /* Check for going out of bounds */ + if(idx >= ltable.nlinks) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5G_UNKNOWN, "index out of bound") + + /* Determine type of object */ + if(ltable.lnks[idx].type == H5L_TYPE_SOFT) + ret_value = H5G_LINK; + else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN) + ret_value = H5G_UDLINK; + else if(ltable.lnks[idx].type == H5L_TYPE_HARD){ + H5O_loc_t tmp_oloc; /* Temporary object location */ + + /* Build temporary object location */ + tmp_oloc.file = oloc->file; + tmp_oloc.addr = ltable.lnks[idx].u.hard.addr; + + /* Get the type of the object */ + if((ret_value = H5O_obj_type(&tmp_oloc, dxpl_id)) == H5G_UNKNOWN) + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") + } else { + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type") + } /* end else */ + +done: + /* Release link table */ + if(ltable.lnks) + /* Free link table information */ + if(H5G_link_release_table(<able) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_compact_get_type_by_idx() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_compact_remove_cb + * + * Purpose: Callback routine for deleting 'link' message for a particular + * name. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Sep 5 2005 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5G_compact_remove_cb(const void *_mesg, unsigned UNUSED idx, void *_udata) +{ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ + H5G_compact_ud2_t *udata = (H5G_compact_ud2_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5O_ITER_CONT; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5G_compact_remove_cb) + + /* check arguments */ + HDassert(lnk); + HDassert(udata); + + /* If we've found the right link, get the object type */ + if(HDstrcmp(lnk->name, udata->name) == 0) { + switch(lnk->type) + { + case H5L_TYPE_HARD: + { + H5O_loc_t tmp_oloc; /* Temporary object location */ + + /* Build temporary object location */ + tmp_oloc.file = udata->file; + tmp_oloc.addr = lnk->u.hard.addr; + + /* Get the type of the object */ + /* Note: no way to check for error :-( */ + *(udata->obj_type) = H5O_obj_type(&tmp_oloc, udata->dxpl_id); + } + break; + + case H5L_TYPE_SOFT: + *(udata->obj_type) = H5G_LINK; + break; + + default: /* User-defined link */ + if(lnk->type < H5L_TYPE_UD_MIN) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type") + + *(udata->obj_type) = H5G_UDLINK; + } + /* Stop the iteration, we found the correct link */ + HGOTO_DONE(H5O_ITER_STOP) + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_compact_remove_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_compact_remove + * + * Purpose: Remove NAME from links. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, September 19, 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_compact_remove(const H5O_loc_t *oloc, const char *name, H5G_obj_t *obj_type, + hid_t dxpl_id) +{ + H5G_compact_ud2_t udata; /* Data to pass through OH iteration */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5G_compact_remove, FAIL) + + HDassert(oloc && oloc->file); + HDassert(name && *name); + + /* Initialize data to pass through object header iteration */ + udata.name = name; + udata.file = oloc->file; + udata.dxpl_id = dxpl_id; + udata.obj_type = obj_type; + + /* Iterate over the link messages to delete the right one */ + if(H5O_remove_op(oloc, H5O_LINK_ID, H5O_FIRST, H5G_compact_remove_cb, &udata, TRUE, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_compact_remove() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_compact_iterate + * + * Purpose: Iterate over the links in a group + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Monday, October 3, 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_compact_iterate(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, + H5_iter_order_t order, hid_t gid, hbool_t lib_internal, int skip, + int *last_obj, H5G_link_iterate_t op, void *op_data) +{ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + size_t u; /* Local index variable */ + herr_t ret_value; + + FUNC_ENTER_NOAPI(H5G_compact_iterate, FAIL) + + /* Sanity check */ + HDassert(oloc); + HDassert(lib_internal || H5I_GROUP == H5I_get_type(gid)); + HDassert(op.lib_op); + + /* Build table of all link messages */ + if(H5G_compact_build_table(oloc, dxpl_id, linfo, H5L_INDEX_NAME, order, <able) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") + + /* Iterate over link messages */ + for(u = 0, ret_value = H5B_ITER_CONT; u < ltable.nlinks && !ret_value; u++) { + if(skip > 0) + --skip; + else { + /* Check for internal callback with link info */ + if(lib_internal) + ret_value = (op.lib_op)(&(ltable.lnks[u]), op_data); + else + ret_value = (op.app_op)(gid, ltable.lnks[u].name, op_data); + } /* end else */ + + /* Increment the number of entries passed through */ + /* (whether we skipped them or not) */ + (*last_obj)++; + } /* end for */ + + /* Check for callback failure and pass along return value */ + if(ret_value < 0) + HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); + +done: + /* Release link table */ + if(ltable.lnks) + /* Free link table information */ + if(H5G_link_release_table(<able) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_compact_iterate() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_compact_lookup_cb + * + * Purpose: Callback routine for searching 'link' messages for a particular + * name & gettting object location for it + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Sep 20 2005 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5G_compact_lookup_cb(const void *_mesg, unsigned UNUSED idx, void *_udata) +{ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ + H5G_compact_ud4_t *udata = (H5G_compact_ud4_t *)_udata; /* 'User data' passed in */ + herr_t ret_value = H5O_ITER_CONT; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5G_compact_lookup_cb) + + /* check arguments */ + HDassert(lnk); + HDassert(udata); + + /* Check for name to get information */ + if(HDstrcmp(lnk->name, udata->name) == 0) { + if(udata->lnk) { + /* Copy link information */ + if(NULL == H5O_copy(H5O_LINK_ID, lnk, udata->lnk)) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5O_ITER_ERROR, "can't copy link message") + } /* end if */ + + /* Indicate that the correct link was found */ + udata->found = TRUE; + + /* Stop iteration now */ + HGOTO_DONE(H5O_ITER_STOP) + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_compact_lookup_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_compact_lookup + * + * Purpose: Look up an object relative to a group, using link messages. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Sep 20 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_compact_lookup(H5O_loc_t *oloc, const char *name, H5O_link_t *lnk, + hid_t dxpl_id) +{ + H5G_compact_ud4_t udata; /* User data for iteration callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5G_compact_lookup, FAIL) + + /* check arguments */ + HDassert(lnk && oloc->file); + HDassert(name && *name); + + /* Set up user data for iteration */ + udata.name = name; + udata.lnk = lnk; + udata.found = FALSE; + + /* Iterate through the link messages, adding them to the table */ + if(H5O_iterate(oloc, H5O_LINK_ID, H5G_compact_lookup_cb, &udata, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over link messages") + + /* Check if we found the link we were looking for */ + if(!udata.found) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_compact_lookup() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_compact_lookup_by_idx + * + * Purpose: Look up an object in a group using link messages, + * according to the order of an index + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Nov 6 2006 + * + *------------------------------------------------------------------------- + */ +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) +{ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5G_compact_lookup_by_idx, FAIL) + + /* check arguments */ + HDassert(oloc && oloc->file); + HDassert(linfo); + HDassert(lnk); + + /* Build table of all link messages, sorted according to desired order */ + if(H5G_compact_build_table(oloc, dxpl_id, linfo, idx_type, order, <able) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") + + /* Check for going out of bounds */ + if(n >= ltable.nlinks) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index out of bound") + + /* Copy link information */ + if(NULL == H5O_copy(H5O_LINK_ID, <able.lnks[n], lnk)) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5O_ITER_ERROR, "can't copy link message") + +done: + /* Release link table */ + if(ltable.lnks) + /* Free link table information */ + if(H5G_link_release_table(<able) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_compact_lookup_by_idx() */ + diff --git a/src/H5Gdense.c b/src/H5Gdense.c index 9e45f6a..3b8be2f 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -704,7 +704,7 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5B2_ITER_ERROR, "can't copy link message") /* Free link table information */ - if(H5G_obj_release_table(<able) < 0) + if(H5G_link_release_table(<able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") } /* end else */ @@ -810,18 +810,18 @@ H5G_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, /* Sort link table in correct iteration order */ if(idx_type == H5L_INDEX_NAME) { if(order == H5_ITER_INC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_obj_cmp_name_inc); + HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_name_inc); else if(order == H5_ITER_DEC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_obj_cmp_name_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 == H5L_INDEX_CRT_ORDER); if(order == H5_ITER_INC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_obj_cmp_corder_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_obj_cmp_corder_dec); + HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_corder_dec); else HDassert(order == H5_ITER_NATIVE); } /* end else */ @@ -1021,7 +1021,7 @@ H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, H5_iter_order_t order, hid_t gid, HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); /* Free link table information */ - if(H5G_obj_release_table(<able) < 0) + if(H5G_link_release_table(<able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") } /* end else */ @@ -1230,7 +1230,7 @@ H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, } /* end if */ /* Free link table information */ - if(H5G_obj_release_table(<able) < 0) + if(H5G_link_release_table(<able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") } /* end else */ @@ -1304,7 +1304,7 @@ H5G_dense_get_type_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, done: /* Release link table */ if(ltable.lnks) - if(H5G_obj_release_table(<able) < 0) + if(H5G_link_release_table(<able) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table") FUNC_LEAVE_NOAPI(ret_value) @@ -1531,6 +1531,9 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link) HDassert(linfo); /* Check if we are to adjust the ref. count for all the links */ + /* (we adjust the ref. count when deleting a group and we _don't_ adjust + * the ref. count when transitioning back to compact storage) + */ if(adj_link) { H5HF_t *fheap = NULL; /* Fractal heap handle */ H5G_bt2_ud_rem_t udata; /* User data for v2 B-tree record removal */ @@ -1548,7 +1551,7 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link) udata.common.found_op = NULL; udata.common.found_op_data = NULL; udata.adj_link = TRUE; - udata.rem_from_fheap = FALSE; + udata.rem_from_fheap = FALSE; /* handled in "bulk" below by deleting entire heap */ udata.rem_from_corder_index = FALSE; udata.obj_type = NULL; diff --git a/src/H5Glink.c b/src/H5Glink.c index 17b8f0a..0600e97 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -15,90 +15,77 @@ /*------------------------------------------------------------------------- * * Created: H5Glink.c - * Sep 5 2005 - * Quincey Koziol + * Nov 13 2006 + * Quincey Koziol * - * Purpose: Functions for handling link messages. + * Purpose: Functions for handling links in groups. * *------------------------------------------------------------------------- */ + +/****************/ +/* Module Setup */ +/****************/ + #define H5G_PACKAGE /*suppress error about including H5Gpkg */ -/* Packages needed by this file... */ +/***********/ +/* Headers */ +/***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Gpkg.h" /* Groups */ #include "H5HLprivate.h" /* Local Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ - -/* Private typedefs */ - -/* User data for link message iteration when building link table */ -typedef struct { - H5G_link_table_t *ltable; /* Pointer to link table to build */ - size_t curr_lnk; /* Current link to operate on */ -} H5G_link_ud1_t; - -/* User data for deleting a link in the link messages */ -typedef struct { - /* downward */ - const char *name; /* Name to search for */ - H5F_t *file; /* File that object header is located within */ - hid_t dxpl_id; /* DXPL during insertion */ - - /* upward */ - H5G_obj_t *obj_type; /* Type of object deleted */ -} H5G_link_ud2_t; - -/* User data for link message iteration when querying object info */ -typedef struct { - /* downward */ - const char *name; /* Name to search for */ - H5F_t *file; /* File that object header is located within */ - hid_t dxpl_id; /* DXPL during insertion */ - - /* upward */ - H5G_stat_t *statbuf; /* Stat buffer for info */ -} H5G_link_ud3_t; - -/* User data for link message iteration when querying object location */ -typedef struct { - /* downward */ - const char *name; /* Name to search for */ - - /* upward */ - H5O_link_t *lnk; /* Link struct to fill in */ - hbool_t found; /* Flag to indicate that the object was found */ -} H5G_link_ud4_t; - -/* User data for link message iteration when querying soft link value */ -typedef struct { - /* downward */ - const char *name; /* Name to search for */ - size_t size; /* Buffer size for link value */ - - /* upward */ - char *buf; /* Buffer to fill with link value */ -} H5G_link_ud5_t; - -/* Private macros */ - -/* PRIVATE PROTOTYPES */ -static herr_t H5G_link_build_table_cb(const void *_mesg, unsigned idx, void *_udata); -static herr_t H5G_link_build_table(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); + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + /*------------------------------------------------------------------------- - * Function: H5G_link_build_table_cb + * Function: H5G_link_cmp_name_inc * - * Purpose: Callback routine for searching 'link' messages for a particular - * name. + * Purpose: Callback routine for comparing two link names, in + * increasing alphabetic order * - * Return: Non-negative on success/Negative on failure + * 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@ncsa.uiuc.edu @@ -106,103 +93,110 @@ static herr_t H5G_link_build_table(H5O_loc_t *oloc, hid_t dxpl_id, * *------------------------------------------------------------------------- */ -static herr_t -H5G_link_build_table_cb(const void *_mesg, unsigned UNUSED idx, void *_udata) +int +H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2) { - const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ - H5G_link_ud1_t *udata = (H5G_link_ud1_t *)_udata; /* 'User data' passed in */ - herr_t ret_value=H5O_ITER_CONT; /* Return value */ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_link_cmp_name_inc) - FUNC_ENTER_NOAPI_NOINIT(H5G_link_build_table_cb) + FUNC_LEAVE_NOAPI(HDstrcmp(((const H5O_link_t *)lnk1)->name, ((const H5O_link_t *)lnk2)->name)) +} /* end H5G_link_cmp_name_inc() */ - /* check arguments */ - HDassert(lnk); - HDassert(udata); - HDassert(udata->curr_lnk < udata->ltable->nlinks); + +/*------------------------------------------------------------------------- + * Function: H5G_link_cmp_name_dec + * + * Purpose: Callback routine for comparing two link names, in + * decreasing alphabetic order + * + * Return: An integer less than, equal to, or greater than zero if the + * second argument is considered to be respectively less than, + * equal to, or greater than the first. If two members compare + * as equal, their order in the sorted array is undefined. + * (i.e. opposite strcmp()) + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Sep 25 2006 + * + *------------------------------------------------------------------------- + */ +int +H5G_link_cmp_name_dec(const void *lnk1, const void *lnk2) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_link_cmp_name_dec) + + FUNC_LEAVE_NOAPI(HDstrcmp(((const H5O_link_t *)lnk2)->name, ((const H5O_link_t *)lnk1)->name)) +} /* end H5G_link_cmp_name_dec() */ - /* Copy link message into table */ - if(NULL == H5O_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk]))) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5O_ITER_ERROR, "can't copy link message") + +/*------------------------------------------------------------------------- + * Function: H5G_link_cmp_corder_inc + * + * Purpose: Callback routine for comparing two link creation orders, in + * increasing 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. + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Nov 6 2006 + * + *------------------------------------------------------------------------- + */ +int +H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2) +{ + int ret_value; /* Return value */ - /* Increment current link entry to operate on */ - udata->curr_lnk++; + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_link_cmp_corder_inc) + + if(((const H5O_link_t *)lnk1)->corder < ((const H5O_link_t *)lnk2)->corder) + ret_value = -1; + else if(((const H5O_link_t *)lnk1)->corder > ((const H5O_link_t *)lnk2)->corder) + ret_value = 1; + else + ret_value = 0; -done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_build_table_cb() */ +} /* end H5G_link_cmp_corder_inc() */ /*------------------------------------------------------------------------- - * Function: H5G_link_build_table + * Function: H5G_link_cmp_corder_dec * - * Purpose: Builds a table containing a sorted (alphabetically) list of - * links for a group + * Purpose: Callback routine for comparing two link creation orders, in + * decreasing order * - * Return: Success: Non-negative - * Failure: Negative + * Return: An integer less than, equal to, or greater than zero if the + * second argument is considered to be respectively less than, + * equal to, or greater than the first. If two members compare + * as equal, their order in the sorted array is undefined. * * Programmer: Quincey Koziol - * Sep 6, 2005 + * koziol@hdfgroup.org + * Nov 6 2006 * *------------------------------------------------------------------------- */ -static herr_t -H5G_link_build_table(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) +int +H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5G_link_build_table) - - /* Sanity check */ - HDassert(oloc); - HDassert(linfo); - HDassert(ltable); + int ret_value; /* Return value */ - /* Set size of table */ - H5_CHECK_OVERFLOW(linfo->nlinks, hsize_t, size_t); - ltable->nlinks = (size_t)linfo->nlinks; + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_link_cmp_corder_dec) - /* Allocate space for the table entries */ - if(ltable->nlinks > 0) { - H5G_link_ud1_t udata; /* User data for iteration callback */ - - if((ltable->lnks = H5MM_malloc(sizeof(H5O_link_t) * ltable->nlinks)) == NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Set up user data for iteration */ - udata.ltable = ltable; - udata.curr_lnk = 0; - - /* Iterate through the link messages, adding them to the table */ - if(H5O_iterate(oloc, H5O_LINK_ID, H5G_link_build_table_cb, &udata, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over link messages") - - /* Sort link table in correct iteration order */ - if(idx_type == H5L_INDEX_NAME) { - if(order == H5_ITER_INC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_obj_cmp_name_inc); - else if(order == H5_ITER_DEC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_obj_cmp_name_dec); - else - HDassert(order == H5_ITER_NATIVE); - } /* end if */ - else { - HDassert(idx_type == H5L_INDEX_CRT_ORDER); - if(order == H5_ITER_INC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_obj_cmp_corder_inc); - else if(order == H5_ITER_DEC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_obj_cmp_corder_dec); - else - HDassert(order == H5_ITER_NATIVE); - } /* end else */ - } /* end if */ + if(((const H5O_link_t *)lnk1)->corder < ((const H5O_link_t *)lnk2)->corder) + ret_value = 1; + else if(((const H5O_link_t *)lnk1)->corder > ((const H5O_link_t *)lnk2)->corder) + ret_value = -1; else - ltable->lnks = NULL; + ret_value = 0; -done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_build_table() */ +} /* end H5G_link_cmp_corder_dec() */ /*------------------------------------------------------------------------- @@ -384,464 +378,43 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_link_insert + * Function: H5G_link_release_table * - * Purpose: Insert a new symbol into the table described by GRP_ENT in - * file F. The name of the new symbol is NAME and its symbol - * table entry is OBJ_ENT. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Sep 6 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_link_insert(H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk, - hid_t dxpl_id) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_link_insert, FAIL) - - /* check arguments */ - HDassert(grp_oloc && grp_oloc->file); - HDassert(obj_lnk); - - /* Insert link message into group */ - if(H5O_modify(grp_oloc, H5O_LINK_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, obj_lnk, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_insert() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_link_get_name_by_idx - * - * Purpose: Returns the name of objects in the group by giving index. - * - * Return: Success: Non-negative, length of name - * Failure: Negative - * - * Programmer: Quincey Koziol - * Sep 6, 2005 - * - *------------------------------------------------------------------------- - */ -ssize_t -H5G_link_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, - hsize_t idx, char* name, size_t size) -{ - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - ssize_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_link_get_name_by_idx, FAIL) - - /* Sanity check */ - HDassert(oloc); - - /* Build table of all link messages */ - if(H5G_link_build_table(oloc, dxpl_id, linfo, idx_type, order, <able) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") - - /* Check for going out of bounds */ - if(idx >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "index out of bound") - - /* Get the length of the name */ - ret_value = (ssize_t)HDstrlen(ltable.lnks[idx].name); - - /* Copy the name into the user's buffer, if given */ - if(name) { - HDstrncpy(name, ltable.lnks[idx].name, MIN((size_t)(ret_value + 1), size)); - if((size_t)ret_value >= size) - name[size - 1]='\0'; - } /* end if */ - -done: - /* Release link table */ - if(ltable.lnks) - /* Free link table information */ - if(H5G_obj_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_get_name_by_idx() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_link_get_type_by_idx - * - * Purpose: Returns the type of objects in the group by giving index. + * Purpose: Release table containing a list of links for a group * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol - * Sep 12, 2005 - * - *------------------------------------------------------------------------- - */ -H5G_obj_t -H5G_link_get_type_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, - hsize_t idx) -{ - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - H5G_obj_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_link_get_type_by_idx, H5G_UNKNOWN) - - /* Sanity check */ - HDassert(oloc); - - /* Build table of all link messages */ - if(H5G_link_build_table(oloc, dxpl_id, linfo, H5L_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 */ - if(idx >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5G_UNKNOWN, "index out of bound") - - /* Determine type of object */ - if(ltable.lnks[idx].type == H5L_TYPE_SOFT) - ret_value = H5G_LINK; - else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN) - ret_value = H5G_UDLINK; - else if(ltable.lnks[idx].type == H5L_TYPE_HARD){ - H5O_loc_t tmp_oloc; /* Temporary object location */ - - /* Build temporary object location */ - tmp_oloc.file = oloc->file; - tmp_oloc.addr = ltable.lnks[idx].u.hard.addr; - - /* Get the type of the object */ - if((ret_value = H5O_obj_type(&tmp_oloc, dxpl_id)) == H5G_UNKNOWN) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") - } else { - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type") - } /* end else */ - -done: - /* Release link table */ - if(ltable.lnks) - /* Free link table information */ - if(H5G_obj_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_get_type_by_idx() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_link_remove_cb - * - * Purpose: Callback routine for deleting 'link' message for a particular - * name. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Sep 5 2005 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_link_remove_cb(const void *_mesg, unsigned UNUSED idx, void *_udata) -{ - const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ - H5G_link_ud2_t *udata = (H5G_link_ud2_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = H5O_ITER_CONT; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5G_link_remove_cb) - - /* check arguments */ - HDassert(lnk); - HDassert(udata); - - /* If we've found the right link, get the object type */ - if(HDstrcmp(lnk->name, udata->name) == 0) { - switch(lnk->type) - { - case H5L_TYPE_HARD: - { - H5O_loc_t tmp_oloc; /* Temporary object location */ - - /* Build temporary object location */ - tmp_oloc.file = udata->file; - tmp_oloc.addr = lnk->u.hard.addr; - - /* Get the type of the object */ - /* Note: no way to check for error :-( */ - *(udata->obj_type) = H5O_obj_type(&tmp_oloc, udata->dxpl_id); - } - break; - - case H5L_TYPE_SOFT: - *(udata->obj_type) = H5G_LINK; - break; - - default: /* User-defined link */ - if(lnk->type < H5L_TYPE_UD_MIN) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type") - - *(udata->obj_type) = H5G_UDLINK; - } - /* Stop the iteration, we found the correct link */ - HGOTO_DONE(H5O_ITER_STOP) - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_remove_cb() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_link_remove - * - * Purpose: Remove NAME from links. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, September 19, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_link_remove(const H5O_loc_t *oloc, const char *name, H5G_obj_t *obj_type, - hid_t dxpl_id) -{ - H5G_link_ud2_t udata; /* Data to pass through OH iteration */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_link_remove, FAIL) - - HDassert(oloc && oloc->file); - HDassert(name && *name); - - /* Initialize data to pass through object header iteration */ - udata.name = name; - udata.file = oloc->file; - udata.dxpl_id = dxpl_id; - udata.obj_type = obj_type; - - /* Iterate over the link messages to delete the right one */ - if(H5O_remove_op(oloc, H5O_LINK_ID, H5O_FIRST, H5G_link_remove_cb, &udata, TRUE, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_remove() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_link_iterate - * - * Purpose: Iterate over the links in a group - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, October 3, 2005 + * Sep 6, 2005 * *------------------------------------------------------------------------- */ herr_t -H5G_link_iterate(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5_iter_order_t order, hid_t gid, hbool_t lib_internal, int skip, - int *last_obj, H5G_link_iterate_t op, void *op_data) +H5G_link_release_table(H5G_link_table_t *ltable) { - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - size_t u; /* Local index variable */ - herr_t ret_value; + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5G_link_iterate, FAIL) + FUNC_ENTER_NOAPI_NOINIT(H5G_link_release_table) /* Sanity check */ - HDassert(oloc); - HDassert(lib_internal || H5I_GROUP == H5I_get_type(gid)); - HDassert(op.lib_op); - - /* Build table of all link messages */ - if(H5G_link_build_table(oloc, dxpl_id, linfo, H5L_INDEX_NAME, order, <able) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") - - /* Iterate over link messages */ - for(u = 0, ret_value = H5B_ITER_CONT; u < ltable.nlinks && !ret_value; u++) { - if(skip > 0) - --skip; - else { - /* Check for internal callback with link info */ - if(lib_internal) - ret_value = (op.lib_op)(&(ltable.lnks[u]), op_data); - else - ret_value = (op.app_op)(gid, ltable.lnks[u].name, op_data); - } /* end else */ - - /* Increment the number of entries passed through */ - /* (whether we skipped them or not) */ - (*last_obj)++; - } /* end for */ - - /* Check for callback failure and pass along return value */ - if(ret_value < 0) - HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); - -done: - /* Release link table */ - if(ltable.lnks) - /* Free link table information */ - if(H5G_obj_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_iterate() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_link_lookup_cb - * - * Purpose: Callback routine for searching 'link' messages for a particular - * name & gettting object location for it - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Sep 20 2005 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_link_lookup_cb(const void *_mesg, unsigned UNUSED idx, void *_udata) -{ - const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ - H5G_link_ud4_t *udata = (H5G_link_ud4_t *)_udata; /* 'User data' passed in */ - herr_t ret_value = H5O_ITER_CONT; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5G_link_lookup_cb) - - /* check arguments */ - HDassert(lnk); - HDassert(udata); - - /* Check for name to get information */ - if(HDstrcmp(lnk->name, udata->name) == 0) { - if(udata->lnk) { - /* Copy link information */ - if(NULL == H5O_copy(H5O_LINK_ID, lnk, udata->lnk)) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5O_ITER_ERROR, "can't copy link message") - } /* end if */ + HDassert(ltable); - /* Indicate that the correct link was found */ - udata->found = TRUE; + /* Release link info, if any */ + if(ltable->nlinks > 0) { + /* Free link message information */ + for(u = 0; u < ltable->nlinks; u++) + if(H5O_reset(H5O_LINK_ID, &(ltable->lnks[u])) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link message") - /* Stop iteration now */ - HGOTO_DONE(H5O_ITER_STOP) + /* Free table of links */ + H5MM_xfree(ltable->lnks); } /* end if */ + else + HDassert(ltable->lnks == NULL); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_lookup_cb() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_link_lookup - * - * Purpose: Look up an object relative to a group, using link messages. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Sep 20 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_link_lookup(H5O_loc_t *oloc, const char *name, H5O_link_t *lnk, - hid_t dxpl_id) -{ - H5G_link_ud4_t udata; /* User data for iteration callback */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_link_lookup, FAIL) - - /* check arguments */ - HDassert(lnk && oloc->file); - HDassert(name && *name); - - /* Set up user data for iteration */ - udata.name = name; - udata.lnk = lnk; - udata.found = FALSE; - - /* Iterate through the link messages, adding them to the table */ - if(H5O_iterate(oloc, H5O_LINK_ID, H5G_link_lookup_cb, &udata, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over link messages") - - /* Check if we found the link we were looking for */ - if(!udata.found) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_lookup() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_link_lookup_by_idx - * - * Purpose: Look up an object in a group using link messages, - * according to the order of an index - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Nov 6 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_link_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) -{ - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_link_lookup_by_idx, FAIL) - - /* check arguments */ - HDassert(oloc && oloc->file); - HDassert(linfo); - HDassert(lnk); - - /* Build table of all link messages, sorted according to desired order */ - if(H5G_link_build_table(oloc, dxpl_id, linfo, idx_type, order, <able) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") - - /* Check for going out of bounds */ - if(n >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index out of bound") - - /* Copy link information */ - if(NULL == H5O_copy(H5O_LINK_ID, <able.lnks[n], lnk)) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5O_ITER_ERROR, "can't copy link message") - -done: - /* Release link table */ - if(ltable.lnks) - /* Free link table information */ - if(H5G_obj_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_lookup_by_idx() */ +} /* end H5G_link_release_table() */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 978cbe2..98123e8 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -260,12 +260,10 @@ H5G_node_encode_key(const H5F_t *f, const H5B_t UNUSED *bt, uint8_t *raw, void * * Programmer: Quincey Koziol * Friday, February 28, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5G_node_debug_key (FILE *stream, H5F_t *f, hid_t dxpl_id, int indent, int fwidth, +H5G_node_debug_key(FILE *stream, H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *_key, const void *_udata) { const H5G_node_key_t *key = (const H5G_node_key_t *) _key; @@ -280,8 +278,7 @@ H5G_node_debug_key (FILE *stream, H5F_t *f, hid_t dxpl_id, int indent, int fwidt HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Heap offset:", (unsigned)key->offset); - if(udata->heap_addr != 0) - { + if(udata->heap_addr != 0) { HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Name:"); if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->heap_addr))) @@ -292,15 +289,13 @@ H5G_node_debug_key (FILE *stream, H5F_t *f, hid_t dxpl_id, int indent, int fwidt if (H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name"); - } + } /* end if */ else - { HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Cannot get name; heap address not specified\n"); - } done: FUNC_LEAVE_NOAPI(ret_value); -} +} /* end H5G_node_debug_key() */ /*------------------------------------------------------------------------- diff --git a/src/H5Gobj.c b/src/H5Gobj.c index a5cea7e..c450e46 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -88,7 +88,7 @@ typedef struct { /********************/ /* Local Prototypes */ /********************/ -static herr_t H5G_obj_link_to_dense_cb(const void *_mesg, unsigned idx, +static herr_t H5G_obj_compact_to_dense_cb(const void *_mesg, unsigned idx, void *_udata); @@ -109,172 +109,6 @@ static herr_t H5G_obj_link_to_dense_cb(const void *_mesg, unsigned idx, /*------------------------------------------------------------------------- - * Function: H5G_obj_cmp_name_inc - * - * Purpose: Callback routine for comparing two link 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@ncsa.uiuc.edu - * Sep 5 2005 - * - *------------------------------------------------------------------------- - */ -int -H5G_obj_cmp_name_inc(const void *lnk1, const void *lnk2) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_obj_cmp_name_inc) - - FUNC_LEAVE_NOAPI(HDstrcmp(((const H5O_link_t *)lnk1)->name, ((const H5O_link_t *)lnk2)->name)) -} /* end H5G_obj_cmp_name_inc() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_obj_cmp_name_dec - * - * Purpose: Callback routine for comparing two link names, in - * decreasing alphabetic order - * - * Return: An integer less than, equal to, or greater than zero if the - * second argument is considered to be respectively less than, - * equal to, or greater than the first. If two members compare - * as equal, their order in the sorted array is undefined. - * (i.e. opposite strcmp()) - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Sep 25 2006 - * - *------------------------------------------------------------------------- - */ -int -H5G_obj_cmp_name_dec(const void *lnk1, const void *lnk2) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_obj_cmp_name_dec) - - FUNC_LEAVE_NOAPI(HDstrcmp(((const H5O_link_t *)lnk2)->name, ((const H5O_link_t *)lnk1)->name)) -} /* end H5G_obj_cmp_name_dec() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_obj_cmp_corder_inc - * - * Purpose: Callback routine for comparing two link creation orders, in - * increasing 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. - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Nov 6 2006 - * - *------------------------------------------------------------------------- - */ -int -H5G_obj_cmp_corder_inc(const void *lnk1, const void *lnk2) -{ - int ret_value; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_obj_cmp_corder_inc) - - if(((const H5O_link_t *)lnk1)->corder < ((const H5O_link_t *)lnk2)->corder) - ret_value = -1; - else if(((const H5O_link_t *)lnk1)->corder > ((const H5O_link_t *)lnk2)->corder) - ret_value = 1; - else - ret_value = 0; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_obj_cmp_corder_inc() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_obj_cmp_corder_dec - * - * Purpose: Callback routine for comparing two link creation orders, in - * decreasing order - * - * Return: An integer less than, equal to, or greater than zero if the - * second argument is considered to be respectively less than, - * equal to, or greater than the first. If two members compare - * as equal, their order in the sorted array is undefined. - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Nov 6 2006 - * - *------------------------------------------------------------------------- - */ -int -H5G_obj_cmp_corder_dec(const void *lnk1, const void *lnk2) -{ - int ret_value; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_obj_cmp_corder_dec) - - if(((const H5O_link_t *)lnk1)->corder < ((const H5O_link_t *)lnk2)->corder) - ret_value = 1; - else if(((const H5O_link_t *)lnk1)->corder > ((const H5O_link_t *)lnk2)->corder) - ret_value = -1; - else - ret_value = 0; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_obj_cmp_corder_dec() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_obj_release_table - * - * Purpose: Release table containing a list of links for a group - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Sep 6, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_obj_release_table(H5G_link_table_t *ltable) -{ - size_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5G_obj_release_table) - - /* Sanity check */ - HDassert(ltable); - - /* Release link info, if any */ - if(ltable->nlinks > 0) { - /* Free link message information */ - for(u = 0; u < ltable->nlinks; u++) - if(H5O_reset(H5O_LINK_ID, &(ltable->lnks[u])) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link message") - - /* Free table of links */ - H5MM_xfree(ltable->lnks); - } /* end if */ - else - HDassert(ltable->lnks == NULL); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_obj_release_table() */ - - -/*------------------------------------------------------------------------- * Function: H5G_obj_create * * Purpose: Create an object header for a group and update object location info @@ -470,9 +304,9 @@ H5G_obj_ent_encode(H5F_t *f, uint8_t **pp, const H5O_loc_t *oloc) /*------------------------------------------------------------------------- - * Function: H5G_obj_link_to_dense_cb + * Function: H5G_obj_compact_to_dense_cb * - * Purpose: Callback routine for converting 'link' messages to "dense" + * Purpose: Callback routine for converting "compact" to "dense" * link storage form. * * Return: Non-negative on success/Negative on failure @@ -484,13 +318,13 @@ H5G_obj_ent_encode(H5F_t *f, uint8_t **pp, const H5O_loc_t *oloc) *------------------------------------------------------------------------- */ static herr_t -H5G_obj_link_to_dense_cb(const void *_mesg, unsigned UNUSED idx, void *_udata) +H5G_obj_compact_to_dense_cb(const void *_mesg, unsigned UNUSED idx, void *_udata) { const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ H5G_obj_oh_it_ud1_t *udata = (H5G_obj_oh_it_ud1_t *)_udata; /* 'User data' passed in */ herr_t ret_value = H5O_ITER_CONT; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5G_obj_link_to_dense_cb) + FUNC_ENTER_NOAPI_NOINIT(H5G_obj_compact_to_dense_cb) /* check arguments */ HDassert(lnk); @@ -502,14 +336,14 @@ H5G_obj_link_to_dense_cb(const void *_mesg, unsigned UNUSED idx, void *_udata) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_obj_link_to_dense_cb() */ +} /* end H5G_obj_compact_to_dense_cb() */ /*------------------------------------------------------------------------- * Function: H5G_obj_stab_to_new_cb * * Purpose: Callback routine for converting "symbol table" link storage to - * "new format" storage (either link messages or "dense" storage). + * "new format" storage (either "compact" or "dense" storage). * * Return: Non-negative on success/Negative on failure * @@ -622,7 +456,7 @@ H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, udata.linfo = &linfo; /* Iterate over the 'link' messages, inserting them into the dense link storage */ - if(H5O_iterate(grp_oloc, H5O_LINK_ID, H5G_obj_link_to_dense_cb, &udata, dxpl_id) < 0) + if(H5O_iterate(grp_oloc, H5O_LINK_ID, H5G_obj_compact_to_dense_cb, &udata, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over links") /* Remove all the 'link' messages */ @@ -696,7 +530,7 @@ H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, } /* end if */ else { /* Insert with link message */ - if(H5G_link_insert(grp_oloc, obj_lnk, dxpl_id) < 0) + if(H5G_compact_insert(grp_oloc, obj_lnk, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert link as link message") } /* end else */ } /* end else */ @@ -784,7 +618,7 @@ H5G_obj_iterate(hid_t loc_id, const char *name, H5_iter_order_t order, } /* end if */ else { /* Get the object's name from the link messages */ - if((ret_value = H5G_link_iterate(&(grp->oloc), dxpl_id, &linfo, order, gid, FALSE, skip, last_lnk, lnk_op, op_data)) < 0) + if((ret_value = H5G_compact_iterate(&(grp->oloc), dxpl_id, &linfo, order, gid, FALSE, skip, last_lnk, lnk_op, op_data)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over links") } /* end else */ } /* end if */ @@ -898,7 +732,7 @@ H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5L_index_t idx_type, } /* end if */ else { /* Get the object's name from the link messages */ - if((ret_value = H5G_link_get_name_by_idx(oloc, dxpl_id, &linfo, idx_type, order, n, name, size)) < 0) + if((ret_value = H5G_compact_get_name_by_idx(oloc, dxpl_id, &linfo, idx_type, order, n, name, size)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate name") } /* end else */ } /* end if */ @@ -955,7 +789,7 @@ H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id) } /* end if */ else { /* Get the object's type from the link messages */ - if((ret_value = H5G_link_get_type_by_idx(oloc, dxpl_id, &linfo, idx)) < 0) + if((ret_value = H5G_compact_get_type_by_idx(oloc, dxpl_id, &linfo, idx)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type") } /* end else */ } /* end if */ @@ -1015,7 +849,7 @@ H5G_obj_remove(H5O_loc_t *oloc, const char *name, H5G_obj_t *obj_type, hid_t dxp } /* end if */ else { /* Remove object from the link messages */ - if(H5G_link_remove(oloc, name, obj_type, dxpl_id) < 0) + if(H5G_compact_remove(oloc, name, obj_type, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end else */ } /* end if */ @@ -1084,7 +918,7 @@ H5G_obj_remove(H5O_loc_t *oloc, const char *name, H5G_obj_t *obj_type, hid_t dxp } /* end if */ /* Free link table information */ - if(H5G_obj_release_table(<able) < 0) + if(H5G_link_release_table(<able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to release link table") } /* end if */ } /* end else */ @@ -1136,7 +970,7 @@ H5G_obj_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, } /* end if */ else { /* Get the object's info from the link messages */ - if(H5G_link_lookup(grp_oloc, name, lnk, dxpl_id) < 0) + if(H5G_compact_lookup(grp_oloc, name, lnk, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end else */ } /* end if */ @@ -1203,7 +1037,7 @@ H5G_obj_lookup_by_idx(H5O_loc_t *grp_oloc, H5L_index_t idx_type, } /* end if */ else { /* Get the link from the link messages */ - if(H5G_link_lookup_by_idx(grp_oloc, dxpl_id, &linfo, idx_type, order, n, lnk) < 0) + if(H5G_compact_lookup_by_idx(grp_oloc, dxpl_id, &linfo, idx_type, order, n, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end else */ } /* end if */ diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 91819f8..b3dc299 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -412,27 +412,34 @@ H5_DLL int H5G_node_by_idx(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t H5_DLL int H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); -/* Functions that understand link messages */ +/* Functions that understand links in groups */ +H5_DLL int H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2); +H5_DLL int H5G_link_cmp_name_dec(const void *lnk1, const void *lnk2); +H5_DLL int H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2); +H5_DLL int H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2); H5_DLL herr_t H5G_link_convert(H5F_t *f, hid_t dxpl_id, H5O_link_t *lnk, haddr_t lheap_addr, const H5G_entry_t *ent, const char *name); 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_insert(H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk, +H5_DLL herr_t H5G_link_release_table(H5G_link_table_t *ltable); + +/* Functions that understand "compact" link storage */ +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_link_get_name_by_idx(H5O_loc_t *oloc, 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, hsize_t idx, char *name, size_t size); -H5_DLL H5G_obj_t H5G_link_get_type_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, +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_link_remove(const H5O_loc_t *oloc, const char *name, +H5_DLL herr_t H5G_compact_remove(const H5O_loc_t *oloc, const char *name, H5G_obj_t *obj_type, hid_t dxpl_id); -H5_DLL herr_t H5G_link_iterate(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, +H5_DLL herr_t H5G_compact_iterate(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, H5_iter_order_t order, hid_t gid, hbool_t lib_internal, int skip, int *last_obj, H5G_link_iterate_t op, void *op_data); -H5_DLL herr_t H5G_link_lookup(H5O_loc_t *grp_oloc, const char *name, +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_link_lookup_by_idx(H5O_loc_t *oloc, 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, hsize_t n, H5O_link_t *lnk); @@ -460,12 +467,7 @@ H5_DLL herr_t H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo H5_DLL herr_t H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link); -/* Functions that understand objects */ -H5_DLL int H5G_obj_cmp_name_inc(const void *lnk1, const void *lnk2); -H5_DLL int H5G_obj_cmp_name_dec(const void *lnk1, const void *lnk2); -H5_DLL int H5G_obj_cmp_corder_inc(const void *lnk1, const void *lnk2); -H5_DLL int H5G_obj_cmp_corder_dec(const void *lnk1, const void *lnk2); -H5_DLL herr_t H5G_obj_release_table(H5G_link_table_t *ltable); +/* Functions that understand group objects */ H5_DLL herr_t H5G_obj_create(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo, const H5O_linfo_t *linfo, H5O_loc_t *oloc/*out*/); H5_DLL herr_t H5G_obj_insert(H5O_loc_t *grp_oloc, const char *name, diff --git a/src/Makefile.am b/src/Makefile.am index fa24970..3f18498 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,8 +50,9 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5FDdirect.c H5FDfamily.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDstdio.c \ H5FDstream.c H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSsection.c \ - H5G.c H5Gbtree2.c H5Gdense.c H5Gdeprec.c H5Gent.c H5Glink.c H5Gloc.c \ - H5Gname.c H5Gnode.c H5Gobj.c H5Goh.c H5Gstab.c H5Gtest.c H5Gtraverse.c \ + H5G.c H5Gbtree2.c H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c H5Glink.c \ + H5Gloc.c H5Gname.c H5Gnode.c H5Gobj.c H5Goh.c H5Gstab.c H5Gtest.c \ + H5Gtraverse.c \ H5HF.c H5HFbtree2.c H5HFcache.c H5HFdbg.c H5HFdblock.c H5HFdtable.c \ H5HFhdr.c H5HFhuge.c H5HFiblock.c H5HFiter.c H5HFman.c H5HFsection.c \ H5HFspace.c H5HFstat.c H5HFtest.c H5HFtiny.c \ diff --git a/src/Makefile.in b/src/Makefile.in index aa65579..ef11c1e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -90,7 +90,7 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5FDdirect.lo H5FDfamily.lo H5FDlog.lo H5FDmpi.lo H5FDmpio.lo \ H5FDmpiposix.lo H5FDmulti.lo H5FDsec2.lo H5FDstdio.lo \ H5FDstream.lo H5FL.lo H5FO.lo H5FS.lo H5FScache.lo H5FSdbg.lo \ - H5FSsection.lo H5G.lo H5Gbtree2.lo H5Gdense.lo H5Gdeprec.lo \ + H5FSsection.lo H5G.lo H5Gbtree2.lo H5Gcompact.lo H5Gdense.lo H5Gdeprec.lo \ H5Gent.lo H5Glink.lo H5Gloc.lo H5Gname.lo H5Gnode.lo H5Gobj.lo \ H5Goh.lo H5Gstab.lo H5Gtest.lo H5Gtraverse.lo H5HF.lo \ H5HFbtree2.lo H5HFcache.lo H5HFdbg.lo H5HFdblock.lo \ @@ -404,7 +404,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5FDdirect.c H5FDfamily.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDstdio.c \ H5FDstream.c H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSsection.c \ - H5G.c H5Gbtree2.c H5Gdense.c H5Gdeprec.c H5Gent.c H5Glink.c H5Gloc.c \ + H5G.c H5Gbtree2.c H5Gcompact.c H5Gdense.c H5Gdeprec.c H5Gent.c H5Glink.c H5Gloc.c \ H5Gname.c H5Gnode.c H5Gobj.c H5Goh.c H5Gstab.c H5Gtest.c H5Gtraverse.c \ H5HF.c H5HFbtree2.c H5HFcache.c H5HFdbg.c H5HFdblock.c H5HFdtable.c \ H5HFhdr.c H5HFhuge.c H5HFiblock.c H5HFiter.c H5HFman.c H5HFsection.c \ @@ -608,6 +608,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Fsuper.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5G.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gbtree2.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gcompact.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gdense.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gdeprec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Gent.Plo@am__quote@ -- cgit v0.12