[svn-r12949] Description:

Finish implementation of H5Literate() [still needs real tests]

    Clean up datatype macro warnings a bit more.

    Unify iterator callback macros and put up in public header file, with the
iterator directions.

Tested on:
    Mac OS X/32 10.4.8 (amazon)
    FreeBSD/32 4.11 (sleipnir)
    Linux/32 2.4 (heping)
    Linux/64 2.4 (mir)
    AIX/32 5.? (copper)
This commit is contained in:
Quincey Koziol 2006-11-20 10:23:29 -05:00
parent 9f55ae114e
commit 98f3bca75e
28 changed files with 936 additions and 493 deletions

View File

@ -1244,10 +1244,10 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
* Perform the iteration operator, which might invoke an * Perform the iteration operator, which might invoke an
* application callback. * application callback.
*/ */
for (u=0, ret_value=H5B_ITER_CONT; u<nchildren && !ret_value; u++) { for(u = 0, ret_value = H5_ITER_CONT; u < nchildren && !ret_value; u++) {
ret_value = (*op)(f, dxpl_id, key+u*type->sizeof_nkey, ret_value = (*op)(f, dxpl_id, key + (u * type->sizeof_nkey),
child[u], key+(u+1)*type->sizeof_nkey, udata); child[u], key + ((u + 1) * type->sizeof_nkey), udata);
if (ret_value<0) if(ret_value < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iterator function failed") HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iterator function failed")
} /* end for */ } /* end for */
} /* end for */ } /* end for */

View File

@ -2121,7 +2121,7 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth,
uint8_t *native = NULL; /* Pointers to copy of node's native records */ uint8_t *native = NULL; /* Pointers to copy of node's native records */
H5B2_node_ptr_t *node_ptrs = NULL; /* Pointers to node's node pointers */ H5B2_node_ptr_t *node_ptrs = NULL; /* Pointers to node's node pointers */
unsigned u; /* Local index */ unsigned u; /* Local index */
herr_t ret_value = H5B2_ITER_CONT; /* Iterator return value */ herr_t ret_value = H5_ITER_CONT; /* Iterator return value */
FUNC_ENTER_NOAPI_NOINIT(H5B2_iterate_node) FUNC_ENTER_NOAPI_NOINIT(H5B2_iterate_node)

View File

@ -36,14 +36,6 @@
/* Library Private Macros */ /* Library Private Macros */
/**************************/ /**************************/
/* Define return values from operator callback function for H5B2_iterate */
/* (Actually, any positive value will cause the iterator to stop and pass back
* that positive value to the function that called the iterator)
*/
#define H5B2_ITER_ERROR (-1)
#define H5B2_ITER_CONT (0)
#define H5B2_ITER_STOP (1)
/****************************/ /****************************/
/* Library Private Typedefs */ /* Library Private Typedefs */

View File

@ -53,14 +53,6 @@
#define H5B_MAGIC "TREE" /*tree node magic number */ #define H5B_MAGIC "TREE" /*tree node magic number */
#define H5B_SIZEOF_MAGIC 4 /*size of magic number */ #define H5B_SIZEOF_MAGIC 4 /*size of magic number */
/* Define return values from operator callback function for H5B_iterate */
/* (Actually, any postive value will cause the iterator to stop and pass back
* that positive value to the function that called the iterator)
*/
#define H5B_ITER_ERROR (-1)
#define H5B_ITER_CONT (0)
#define H5B_ITER_STOP (1)
/****************************/ /****************************/
/* Library Private Typedefs */ /* Library Private Typedefs */
/****************************/ /****************************/

View File

@ -888,7 +888,7 @@ H5D_istore_iter_allocated (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_l
udata->total_storage += lt_key->nbytes; udata->total_storage += lt_key->nbytes;
FUNC_LEAVE_NOAPI(H5B_ITER_CONT) FUNC_LEAVE_NOAPI(H5_ITER_CONT)
} /* H5D_istore_iter_allocated() */ } /* H5D_istore_iter_allocated() */
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
@ -914,7 +914,7 @@ H5D_istore_iter_chunkmap (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_lt
const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key; const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key;
unsigned rank; unsigned rank;
hsize_t chunk_index; hsize_t chunk_index;
int ret_value = H5B_ITER_CONT; /* Return value */ int ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5D_istore_iter_chunkmap); FUNC_ENTER_NOAPI_NOINIT(H5D_istore_iter_chunkmap);
@ -970,7 +970,7 @@ H5D_istore_iter_dump (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_lt_key
HDfputs("]\n", udata->stream); HDfputs("]\n", udata->stream);
} /* end if */ } /* end if */
FUNC_LEAVE_NOAPI(H5B_ITER_CONT) FUNC_LEAVE_NOAPI(H5_ITER_CONT)
} /* H5D_istore_iter_dump() */ } /* H5D_istore_iter_dump() */
@ -1009,7 +1009,7 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key,
size_t nbytes = lt_key->nbytes; size_t nbytes = lt_key->nbytes;
H5Z_cb_t cb_struct; H5Z_cb_t cb_struct;
int ret_value = H5B_ITER_CONT; /* Return value */ int ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5D_istore_iter_copy) FUNC_ENTER_NOAPI_NOINIT(H5D_istore_iter_copy)
@ -1033,10 +1033,10 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key,
if(nbytes > buf_size) { if(nbytes > buf_size) {
/* Re-allocate memory for copying the chunk */ /* Re-allocate memory for copying the chunk */
if(NULL == (udata->buf = H5MM_realloc(udata->buf, nbytes))) if(NULL == (udata->buf = H5MM_realloc(udata->buf, nbytes)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5B_ITER_ERROR, "memory allocation failed for raw data chunk") HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk")
if(udata->bkg) { if(udata->bkg) {
if(NULL == (udata->bkg = H5MM_realloc(udata->bkg, nbytes))) if(NULL == (udata->bkg = H5MM_realloc(udata->bkg, nbytes)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5B_ITER_ERROR, "memory allocation failed for raw data chunk") HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk")
if(!udata->cpy_info->expand_ref) if(!udata->cpy_info->expand_ref)
HDmemset((uint8_t *)udata->bkg + buf_size, 0, (size_t)(nbytes - buf_size)); HDmemset((uint8_t *)udata->bkg + buf_size, 0, (size_t)(nbytes - buf_size));
@ -1049,14 +1049,14 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key,
/* read chunk data from the source file */ /* read chunk data from the source file */
if(H5F_block_read(f_src, H5FD_MEM_DRAW, addr_src, nbytes, dxpl_id, buf) < 0) if(H5F_block_read(f_src, H5FD_MEM_DRAW, addr_src, nbytes, dxpl_id, buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_READERROR, H5B_ITER_ERROR, "unable to read raw data chunk") HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk")
/* Need to uncompress variable-length & reference data elements */ /* Need to uncompress variable-length & reference data elements */
if(is_compressed && (is_vlen || fix_ref)) { if(is_compressed && (is_vlen || fix_ref)) {
unsigned filter_mask = lt_key->filter_mask; unsigned filter_mask = lt_key->filter_mask;
if(H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &filter_mask, edc_read, cb_struct, &nbytes, &buf_size, &buf) < 0) if(H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &filter_mask, edc_read, cb_struct, &nbytes, &buf_size, &buf) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5B_ITER_ERROR, "data pipeline read failed") HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "data pipeline read failed")
} /* end if */ } /* end if */
/* Perform datatype conversion, if necessary */ /* Perform datatype conversion, if necessary */
@ -1073,7 +1073,7 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key,
/* Convert from source file to memory */ /* Convert from source file to memory */
if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, NULL, dxpl_id) < 0) if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, NULL, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5B_ITER_ERROR, "datatype conversion failed") HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "datatype conversion failed")
/* Copy into another buffer, to reclaim memory later */ /* Copy into another buffer, to reclaim memory later */
HDmemcpy(reclaim_buf, buf, reclaim_buf_size); HDmemcpy(reclaim_buf, buf, reclaim_buf_size);
@ -1083,11 +1083,11 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key,
/* Convert from memory to destination file */ /* Convert from memory to destination file */
if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0) if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5B_ITER_ERROR, "datatype conversion failed") HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "datatype conversion failed")
/* Reclaim space from variable length data */ /* Reclaim space from variable length data */
if(H5D_vlen_reclaim(tid_mem, buf_space, H5P_DATASET_XFER_DEFAULT, reclaim_buf) < 0) if(H5D_vlen_reclaim(tid_mem, buf_space, H5P_DATASET_XFER_DEFAULT, reclaim_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, H5B_ITER_ERROR, "unable to reclaim variable-length data") HGOTO_ERROR(H5E_DATASET, H5E_BADITER, H5_ITER_ERROR, "unable to reclaim variable-length data")
} /* end if */ } /* end if */
else if(fix_ref) { else if(fix_ref) {
/* Check for expanding references */ /* Check for expanding references */
@ -1116,7 +1116,7 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key,
if(is_compressed && (is_vlen || fix_ref) ) { if(is_compressed && (is_vlen || fix_ref) ) {
if(H5Z_pipeline(pline, 0, &(udata_dst.common.key.filter_mask), edc_read, if(H5Z_pipeline(pline, 0, &(udata_dst.common.key.filter_mask), edc_read,
cb_struct, &nbytes, &buf_size, &buf) < 0) cb_struct, &nbytes, &buf_size, &buf) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5B_ITER_ERROR, "output pipeline failed") HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed")
udata_dst.common.key.nbytes = nbytes; udata_dst.common.key.nbytes = nbytes;
udata->buf = buf; udata->buf = buf;
udata->buf_size = buf_size; udata->buf_size = buf_size;
@ -1124,12 +1124,12 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key,
/* Insert chunk into the destination Btree */ /* Insert chunk into the destination Btree */
if(H5B_insert(udata->file_dst, dxpl_id, H5B_ISTORE, udata->addr_dst, &udata_dst) < 0) if(H5B_insert(udata->file_dst, dxpl_id, H5B_ISTORE, udata->addr_dst, &udata_dst) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, H5B_ITER_ERROR, "unable to allocate chunk") HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, H5_ITER_ERROR, "unable to allocate chunk")
/* Write chunk data to destination file */ /* Write chunk data to destination file */
HDassert(H5F_addr_defined(udata_dst.addr)); HDassert(H5F_addr_defined(udata_dst.addr));
if(H5F_block_write(udata->file_dst, H5FD_MEM_DRAW, udata_dst.addr, nbytes, dxpl_id, buf) < 0) if(H5F_block_write(udata->file_dst, H5FD_MEM_DRAW, udata_dst.addr, nbytes, dxpl_id, buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, H5B_ITER_ERROR, "unable to write raw data to file") HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, H5_ITER_ERROR, "unable to write raw data to file")
done: done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
@ -3119,7 +3119,7 @@ H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t UN
H5D_istore_it_ud3_t *udata = (H5D_istore_it_ud3_t *)_udata; H5D_istore_it_ud3_t *udata = (H5D_istore_it_ud3_t *)_udata;
const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key; const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key;
unsigned u; unsigned u;
int ret_value = H5B_ITER_CONT; /* Return value */ int ret_value = H5_ITER_CONT; /* Return value */
/* The LT_KEY is the left key (the one that describes the chunk). It points to a chunk of /* The LT_KEY is the left key (the one that describes the chunk). It points to a chunk of
* storage that contains the beginning of the logical address space represented by UDATA. * storage that contains the beginning of the logical address space represented by UDATA.
@ -3138,7 +3138,7 @@ H5D_istore_prune_extent(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t UN
/* Remove */ /* Remove */
if(H5B_remove(f, dxpl_id, H5B_ISTORE, udata->common.mesg->u.chunk.addr, &bt_udata) < 0) if(H5B_remove(f, dxpl_id, H5B_ISTORE, udata->common.mesg->u.chunk.addr, &bt_udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_ITER_ERROR, "unable to remove entry") HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5_ITER_ERROR, "unable to remove entry")
break; break;
} /* end if */ } /* end if */

View File

@ -168,6 +168,7 @@ hid_t H5E_TRAVERSE_g = FAIL; /* Link traversal failure */
hid_t H5E_NLINKS_g = FAIL; /* Too many soft links in path */ hid_t H5E_NLINKS_g = FAIL; /* Too many soft links in path */
hid_t H5E_NOTREGISTERED_g = FAIL; /* Link class not registered */ hid_t H5E_NOTREGISTERED_g = FAIL; /* Link class not registered */
hid_t H5E_CANTMOVE_g = FAIL; /* Move callback returned error */ hid_t H5E_CANTMOVE_g = FAIL; /* Move callback returned error */
hid_t H5E_CANTSORT_g = FAIL; /* Can't sort objects */
/* Parallel MPI errors */ /* Parallel MPI errors */
hid_t H5E_MPI_g = FAIL; /* Some MPI function failed */ hid_t H5E_MPI_g = FAIL; /* Some MPI function failed */
@ -182,6 +183,13 @@ hid_t H5E_CANTNEXT_g = FAIL; /* Can't move to next iterator location
hid_t H5E_BADSELECT_g = FAIL; /* Invalid selection */ hid_t H5E_BADSELECT_g = FAIL; /* Invalid selection */
hid_t H5E_CANTCOMPARE_g = FAIL; /* Can't compare objects */ hid_t H5E_CANTCOMPARE_g = FAIL; /* Can't compare objects */
/* Argument errors */
hid_t H5E_UNINITIALIZED_g = FAIL; /* Information is uinitialized */
hid_t H5E_UNSUPPORTED_g = FAIL; /* Feature is unsupported */
hid_t H5E_BADTYPE_g = FAIL; /* Inappropriate type */
hid_t H5E_BADRANGE_g = FAIL; /* Out of range */
hid_t H5E_BADVALUE_g = FAIL; /* Bad value */
/* B-tree related errors */ /* B-tree related errors */
hid_t H5E_NOTFOUND_g = FAIL; /* Object not found */ hid_t H5E_NOTFOUND_g = FAIL; /* Object not found */
hid_t H5E_EXISTS_g = FAIL; /* Object already exists */ hid_t H5E_EXISTS_g = FAIL; /* Object already exists */
@ -195,13 +203,6 @@ hid_t H5E_CANTLIST_g = FAIL; /* Unable to list node */
hid_t H5E_CANTMODIFY_g = FAIL; /* Unable to modify record */ hid_t H5E_CANTMODIFY_g = FAIL; /* Unable to modify record */
hid_t H5E_CANTREMOVE_g = FAIL; /* Unable to remove object */ hid_t H5E_CANTREMOVE_g = FAIL; /* Unable to remove object */
/* Argument errors */
hid_t H5E_UNINITIALIZED_g = FAIL; /* Information is uinitialized */
hid_t H5E_UNSUPPORTED_g = FAIL; /* Feature is unsupported */
hid_t H5E_BADTYPE_g = FAIL; /* Inappropriate type */
hid_t H5E_BADRANGE_g = FAIL; /* Out of range */
hid_t H5E_BADVALUE_g = FAIL; /* Bad value */
/* Datatype conversion errors */ /* Datatype conversion errors */
hid_t H5E_CANTCONVERT_g = FAIL; /* Can't convert datatypes */ hid_t H5E_CANTCONVERT_g = FAIL; /* Can't convert datatypes */
hid_t H5E_BADSIZE_g = FAIL; /* Bad size for object */ hid_t H5E_BADSIZE_g = FAIL; /* Bad size for object */

View File

@ -638,6 +638,11 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Move callback returned error"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_CANTMOVE_g = H5I_register(H5I_ERROR_MSG, msg))<0) if((H5E_CANTMOVE_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
assert(H5E_CANTSORT_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't sort objects"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_CANTSORT_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
/* Parallel MPI errors */ /* Parallel MPI errors */
assert(H5E_MPI_g==(-1)); assert(H5E_MPI_g==(-1));
@ -688,6 +693,33 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't compare objects"))==NULL)
if((H5E_CANTCOMPARE_g = H5I_register(H5I_ERROR_MSG, msg))<0) if((H5E_CANTCOMPARE_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
/* Argument errors */
assert(H5E_UNINITIALIZED_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Information is uinitialized"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_UNINITIALIZED_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
assert(H5E_UNSUPPORTED_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Feature is unsupported"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_UNSUPPORTED_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
assert(H5E_BADTYPE_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Inappropriate type"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_BADTYPE_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
assert(H5E_BADRANGE_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Out of range"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_BADRANGE_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
assert(H5E_BADVALUE_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Bad value"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_BADVALUE_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
/* B-tree related errors */ /* B-tree related errors */
assert(H5E_NOTFOUND_g==(-1)); assert(H5E_NOTFOUND_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Object not found"))==NULL) if((msg = H5E_create_msg(cls, H5E_MINOR, "Object not found"))==NULL)
@ -745,33 +777,6 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Unable to remove object"))==NULL)
if((H5E_CANTREMOVE_g = H5I_register(H5I_ERROR_MSG, msg))<0) if((H5E_CANTREMOVE_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
/* Argument errors */
assert(H5E_UNINITIALIZED_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Information is uinitialized"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_UNINITIALIZED_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
assert(H5E_UNSUPPORTED_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Feature is unsupported"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_UNSUPPORTED_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
assert(H5E_BADTYPE_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Inappropriate type"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_BADTYPE_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
assert(H5E_BADRANGE_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Out of range"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_BADRANGE_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
assert(H5E_BADVALUE_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Bad value"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_BADVALUE_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
/* Datatype conversion errors */ /* Datatype conversion errors */
assert(H5E_CANTCONVERT_g==(-1)); assert(H5E_CANTCONVERT_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't convert datatypes"))==NULL) if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't convert datatypes"))==NULL)

View File

@ -285,10 +285,12 @@ H5_DLLVAR hid_t H5E_CANTRESIZE_g; /* Unable to resize a metadata cache entry
#define H5E_NLINKS (H5OPEN H5E_NLINKS_g) #define H5E_NLINKS (H5OPEN H5E_NLINKS_g)
#define H5E_NOTREGISTERED (H5OPEN H5E_NOTREGISTERED_g) #define H5E_NOTREGISTERED (H5OPEN H5E_NOTREGISTERED_g)
#define H5E_CANTMOVE (H5OPEN H5E_CANTMOVE_g) #define H5E_CANTMOVE (H5OPEN H5E_CANTMOVE_g)
#define H5E_CANTSORT (H5OPEN H5E_CANTSORT_g)
H5_DLLVAR hid_t H5E_TRAVERSE_g; /* Link traversal failure */ H5_DLLVAR hid_t H5E_TRAVERSE_g; /* Link traversal failure */
H5_DLLVAR hid_t H5E_NLINKS_g; /* Too many soft links in path */ H5_DLLVAR hid_t H5E_NLINKS_g; /* Too many soft links in path */
H5_DLLVAR hid_t H5E_NOTREGISTERED_g; /* Link class not registered */ H5_DLLVAR hid_t H5E_NOTREGISTERED_g; /* Link class not registered */
H5_DLLVAR hid_t H5E_CANTMOVE_g; /* Move callback returned error */ H5_DLLVAR hid_t H5E_CANTMOVE_g; /* Move callback returned error */
H5_DLLVAR hid_t H5E_CANTSORT_g; /* Can't sort objects */
/* Parallel MPI errors */ /* Parallel MPI errors */
#define H5E_MPI (H5OPEN H5E_MPI_g) #define H5E_MPI (H5OPEN H5E_MPI_g)
@ -312,6 +314,18 @@ H5_DLLVAR hid_t H5E_CANTNEXT_g; /* Can't move to next iterator location */
H5_DLLVAR hid_t H5E_BADSELECT_g; /* Invalid selection */ H5_DLLVAR hid_t H5E_BADSELECT_g; /* Invalid selection */
H5_DLLVAR hid_t H5E_CANTCOMPARE_g; /* Can't compare objects */ H5_DLLVAR hid_t H5E_CANTCOMPARE_g; /* Can't compare objects */
/* Argument errors */
#define H5E_UNINITIALIZED (H5OPEN H5E_UNINITIALIZED_g)
#define H5E_UNSUPPORTED (H5OPEN H5E_UNSUPPORTED_g)
#define H5E_BADTYPE (H5OPEN H5E_BADTYPE_g)
#define H5E_BADRANGE (H5OPEN H5E_BADRANGE_g)
#define H5E_BADVALUE (H5OPEN H5E_BADVALUE_g)
H5_DLLVAR hid_t H5E_UNINITIALIZED_g; /* Information is uinitialized */
H5_DLLVAR hid_t H5E_UNSUPPORTED_g; /* Feature is unsupported */
H5_DLLVAR hid_t H5E_BADTYPE_g; /* Inappropriate type */
H5_DLLVAR hid_t H5E_BADRANGE_g; /* Out of range */
H5_DLLVAR hid_t H5E_BADVALUE_g; /* Bad value */
/* B-tree related errors */ /* B-tree related errors */
#define H5E_NOTFOUND (H5OPEN H5E_NOTFOUND_g) #define H5E_NOTFOUND (H5OPEN H5E_NOTFOUND_g)
#define H5E_EXISTS (H5OPEN H5E_EXISTS_g) #define H5E_EXISTS (H5OPEN H5E_EXISTS_g)
@ -336,18 +350,6 @@ H5_DLLVAR hid_t H5E_CANTLIST_g; /* Unable to list node */
H5_DLLVAR hid_t H5E_CANTMODIFY_g; /* Unable to modify record */ H5_DLLVAR hid_t H5E_CANTMODIFY_g; /* Unable to modify record */
H5_DLLVAR hid_t H5E_CANTREMOVE_g; /* Unable to remove object */ H5_DLLVAR hid_t H5E_CANTREMOVE_g; /* Unable to remove object */
/* Argument errors */
#define H5E_UNINITIALIZED (H5OPEN H5E_UNINITIALIZED_g)
#define H5E_UNSUPPORTED (H5OPEN H5E_UNSUPPORTED_g)
#define H5E_BADTYPE (H5OPEN H5E_BADTYPE_g)
#define H5E_BADRANGE (H5OPEN H5E_BADRANGE_g)
#define H5E_BADVALUE (H5OPEN H5E_BADVALUE_g)
H5_DLLVAR hid_t H5E_UNINITIALIZED_g; /* Information is uinitialized */
H5_DLLVAR hid_t H5E_UNSUPPORTED_g; /* Feature is unsupported */
H5_DLLVAR hid_t H5E_BADTYPE_g; /* Inappropriate type */
H5_DLLVAR hid_t H5E_BADRANGE_g; /* Out of range */
H5_DLLVAR hid_t H5E_BADVALUE_g; /* Bad value */
/* Datatype conversion errors */ /* Datatype conversion errors */
#define H5E_CANTCONVERT (H5OPEN H5E_CANTCONVERT_g) #define H5E_CANTCONVERT (H5OPEN H5E_CANTCONVERT_g)
#define H5E_BADSIZE (H5OPEN H5E_BADSIZE_g) #define H5E_BADSIZE (H5OPEN H5E_BADSIZE_g)

View File

@ -169,7 +169,8 @@ H5E_CANTRESIZE_g=
H5E_TRAVERSE_g= H5E_TRAVERSE_g=
H5E_NLINKS_g= H5E_NLINKS_g=
H5E_NOTREGISTERED_g= H5E_NOTREGISTERED_g=
H5E_CANTMOVE_g= H5E_CANTMOVE_g=
H5E_CANTSORT_g=
/* Parallel MPI errors */ /* Parallel MPI errors */
H5E_MPI_g= H5E_MPI_g=
@ -184,6 +185,13 @@ H5E_CANTNEXT_g=
H5E_BADSELECT_g= H5E_BADSELECT_g=
H5E_CANTCOMPARE_g= H5E_CANTCOMPARE_g=
/* Argument errors */
H5E_UNINITIALIZED_g=
H5E_UNSUPPORTED_g=
H5E_BADTYPE_g=
H5E_BADRANGE_g=
H5E_BADVALUE_g=
/* B-tree related errors */ /* B-tree related errors */
H5E_NOTFOUND_g= H5E_NOTFOUND_g=
H5E_EXISTS_g= H5E_EXISTS_g=
@ -197,13 +205,6 @@ H5E_CANTLIST_g=
H5E_CANTMODIFY_g= H5E_CANTMODIFY_g=
H5E_CANTREMOVE_g= H5E_CANTREMOVE_g=
/* Argument errors */
H5E_UNINITIALIZED_g=
H5E_UNSUPPORTED_g=
H5E_BADTYPE_g=
H5E_BADRANGE_g=
H5E_BADVALUE_g=
/* Datatype conversion errors */ /* Datatype conversion errors */
H5E_CANTCONVERT_g= H5E_CANTCONVERT_g=
H5E_BADSIZE_g= (-1); H5E_BADSIZE_g= (-1);

View File

@ -547,77 +547,6 @@ done:
FUNC_LEAVE_API(ret_value); FUNC_LEAVE_API(ret_value);
} }
/*-------------------------------------------------------------------------
* Function: H5Giterate
*
* Purpose: Iterates over the entries of a group. The LOC_ID and NAME
* identify the group over which to iterate and IDX indicates
* where to start iterating (zero means at the beginning). The
* OPERATOR is called for each member and the iteration
* continues until the operator returns non-zero or all members
* are processed. The operator is passed a group ID for the
* group being iterated, a member name, and OP_DATA for each
* member.
*
* Return: Success: The return value of the first operator that
* returns non-zero, or zero if all members were
* processed with no operator returning non-zero.
*
* Failure: Negative if something goes wrong within the
* library, or the negative value returned by one
* of the operators.
*
* Programmer: Robb Matzke
* Monday, March 23, 1998
*
*-------------------------------------------------------------------------
*/
herr_t
H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op,
void *op_data)
{
H5G_link_iterate_t lnk_op; /* Link operator */
hsize_t last_obj; /* Index of last object looked at */
hsize_t idx; /* Internal location to hold index */
herr_t ret_value;
FUNC_ENTER_API(H5Giterate, FAIL)
H5TRACE5("e","is*Isxx",loc_id,name,idx_p,op,op_data);
/* Check args */
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
if(idx_p && *idx_p < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified")
if(!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified")
/* Set number of objects looked at to zero */
last_obj = 0;
idx = (hsize_t)(idx_p == NULL ? 0 : *idx_p);
/* Build link operator info */
lnk_op.op_type = H5G_LINK_OP_OLD;
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)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed")
/* Check for too high of a starting index (ex post facto :-) */
/* (Skipping exactly as many entries as are in the group is currently an error) */
if(idx > 0 && idx >= last_obj)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified")
/* Set the index we stopped at */
if(idx_p)
*idx_p = (int)last_obj;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Giterate() */
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function: H5Gget_num_objs * Function: H5Gget_num_objs

View File

@ -86,7 +86,7 @@ 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 */ const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */
H5G_iter_bt_t *udata = (H5G_iter_bt_t *)_udata; /* 'User data' passed in */ H5G_iter_bt_t *udata = (H5G_iter_bt_t *)_udata; /* 'User data' passed in */
herr_t ret_value=H5O_ITER_CONT; /* Return value */ herr_t ret_value=H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_compact_build_table_cb) FUNC_ENTER_NOAPI_NOINIT(H5G_compact_build_table_cb)
@ -97,7 +97,7 @@ H5G_compact_build_table_cb(const void *_mesg, unsigned UNUSED idx, void *_udata)
/* Copy link message into table */ /* Copy link message into table */
if(NULL == H5O_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk]))) 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") HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message")
/* Increment current link entry to operate on */ /* Increment current link entry to operate on */
udata->curr_lnk++; udata->curr_lnk++;
@ -142,6 +142,7 @@ H5G_compact_build_table(const H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t
if(ltable->nlinks > 0) { if(ltable->nlinks > 0) {
H5G_iter_bt_t udata; /* User data for iteration callback */ H5G_iter_bt_t udata; /* User data for iteration callback */
/* Allocate the link table */
if((ltable->lnks = H5MM_malloc(sizeof(H5O_link_t) * ltable->nlinks)) == NULL) if((ltable->lnks = H5MM_malloc(sizeof(H5O_link_t) * ltable->nlinks)) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
@ -154,23 +155,8 @@ H5G_compact_build_table(const H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over link messages") HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over link messages")
/* Sort link table in correct iteration order */ /* Sort link table in correct iteration order */
if(idx_type == H5L_INDEX_NAME) { if(H5G_link_sort_table(ltable, idx_type, order) < 0)
if(order == H5_ITER_INC) HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting link messages")
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 */ } /* end if */
else else
ltable->lnks = NULL; ltable->lnks = NULL;
@ -349,7 +335,7 @@ H5G_compact_remove_common_cb(const void *_mesg, unsigned UNUSED idx, void *_udat
{ {
const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */
H5G_iter_rm_t *udata = (H5G_iter_rm_t *)_udata; /* 'User data' passed in */ H5G_iter_rm_t *udata = (H5G_iter_rm_t *)_udata; /* 'User data' passed in */
herr_t ret_value = H5O_ITER_CONT; /* Return value */ herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_compact_remove_common_cb) FUNC_ENTER_NOAPI_NOINIT(H5G_compact_remove_common_cb)
@ -361,10 +347,10 @@ H5G_compact_remove_common_cb(const void *_mesg, unsigned UNUSED idx, void *_udat
if(HDstrcmp(lnk->name, udata->name) == 0) { if(HDstrcmp(lnk->name, udata->name) == 0) {
/* Determine the object's type */ /* Determine the object's type */
if(H5G_link_name_replace(udata->file, udata->dxpl_id, udata->grp_full_path_r, lnk->name, lnk->type, lnk->u.hard.addr) < 0) if(H5G_link_name_replace(udata->file, udata->dxpl_id, udata->grp_full_path_r, lnk->name, lnk->type, lnk->u.hard.addr) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5O_ITER_ERROR, "unable to get object type") HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get object type")
/* Stop the iteration, we found the correct link */ /* Stop the iteration, we found the correct link */
HGOTO_DONE(H5O_ITER_STOP) HGOTO_DONE(H5_ITER_STOP)
} /* end if */ } /* end if */
done: done:
@ -478,12 +464,11 @@ done:
*/ */
herr_t herr_t
H5G_compact_iterate(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, 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_obj, 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) hid_t gid, H5G_link_iterate_t *lnk_op, void *op_data)
{ {
H5G_link_table_t ltable = {0, NULL}; /* Link table */ H5G_link_table_t ltable = {0, NULL}; /* Link table */
size_t u; /* Local index variable */ herr_t ret_value; /* Return value */
herr_t ret_value;
FUNC_ENTER_NOAPI(H5G_compact_iterate, FAIL) FUNC_ENTER_NOAPI(H5G_compact_iterate, FAIL)
@ -496,44 +481,8 @@ H5G_compact_iterate(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo,
if(H5G_compact_build_table(oloc, dxpl_id, linfo, idx_type, order, &ltable) < 0) if(H5G_compact_build_table(oloc, dxpl_id, linfo, idx_type, order, &ltable) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table")
/* Iterate over link messages */ /* Iterate over links in table */
for(u = 0, ret_value = H5O_ITER_CONT; u < ltable.nlinks && !ret_value; u++) { if((ret_value = H5G_link_iterate_table(&ltable, skip, last_lnk, gid, lnk_op, op_data)) < 0)
if(skip > 0)
--skip;
else {
/* Check which kind of callback to make */
switch(lnk_op->op_type) {
case H5G_LINK_OP_OLD:
/* Make the old-type application callback */
ret_value = (lnk_op->u.old_op)(gid, ltable.lnks[u].name, op_data);
break;
case H5G_LINK_OP_APP:
{
H5L_info_t info; /* Link info */
/* Retrieve the info for the link */
if(H5G_link_to_info(&(ltable.lnks[u]), &info) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B2_ITER_ERROR, "unable to get info for link")
/* Make the application callback */
ret_value = (lnk_op->u.app_op)(gid, ltable.lnks[u].name, &info, op_data);
}
break;
case H5G_LINK_OP_LIB:
/* Call the library's callback */
ret_value = (lnk_op->u.lib_op)(&(ltable.lnks[u]), op_data);
} /* end switch */
} /* 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"); HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed");
done: done:
@ -564,7 +513,7 @@ 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 */ const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */
H5G_iter_lkp_t *udata = (H5G_iter_lkp_t *)_udata; /* 'User data' passed in */ H5G_iter_lkp_t *udata = (H5G_iter_lkp_t *)_udata; /* 'User data' passed in */
herr_t ret_value = H5O_ITER_CONT; /* Return value */ herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_compact_lookup_cb) FUNC_ENTER_NOAPI_NOINIT(H5G_compact_lookup_cb)
@ -577,14 +526,14 @@ H5G_compact_lookup_cb(const void *_mesg, unsigned UNUSED idx, void *_udata)
if(udata->lnk) { if(udata->lnk) {
/* Copy link information */ /* Copy link information */
if(NULL == H5O_copy(H5O_LINK_ID, lnk, udata->lnk)) if(NULL == H5O_copy(H5O_LINK_ID, lnk, udata->lnk))
HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5O_ITER_ERROR, "can't copy link message") HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message")
} /* end if */ } /* end if */
/* Indicate that the correct link was found */ /* Indicate that the correct link was found */
udata->found = TRUE; udata->found = TRUE;
/* Stop iteration now */ /* Stop iteration now */
HGOTO_DONE(H5O_ITER_STOP) HGOTO_DONE(H5_ITER_STOP)
} /* end if */ } /* end if */
done: done:
@ -674,7 +623,7 @@ H5G_compact_lookup_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *lin
/* Copy link information */ /* Copy link information */
if(NULL == H5O_copy(H5O_LINK_ID, &ltable.lnks[n], lnk)) if(NULL == H5O_copy(H5O_LINK_ID, &ltable.lnks[n], lnk))
HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5O_ITER_ERROR, "can't copy link message") HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message")
done: done:
/* Release link table */ /* Release link table */

View File

@ -487,7 +487,7 @@ H5G_dense_lookup_cb(const void *_lnk, void *_user_lnk)
if(user_lnk) { if(user_lnk) {
/* Copy link information */ /* Copy link information */
if(H5O_copy(H5O_LINK_ID, lnk, user_lnk) == NULL) if(H5O_copy(H5O_LINK_ID, lnk, user_lnk) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5O_ITER_ERROR, "can't copy link message") HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message")
} /* end if */ } /* end if */
done: done:
@ -582,7 +582,7 @@ H5G_dense_lookup_by_idx_fh_cb(const void *obj, size_t UNUSED obj_len, void *_uda
/* Copy link information */ /* Copy link information */
if(NULL == H5O_copy(H5O_LINK_ID, tmp_lnk, udata->lnk)) if(NULL == H5O_copy(H5O_LINK_ID, tmp_lnk, udata->lnk))
HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5B2_ITER_ERROR, "can't copy link message") HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message")
done: done:
if(tmp_lnk) if(tmp_lnk)
@ -597,7 +597,7 @@ done:
* *
* Purpose: v2 B-tree callback for dense link storage lookup by index * Purpose: v2 B-tree callback for dense link storage lookup by index
* *
* Return: H5B2_ITER_ERROR/H5B2_ITER_CONT/H5B2_ITER_STOP * Return: H5_ITER_ERROR/H5_ITER_CONT/H5_ITER_STOP
* *
* Programmer: Quincey Koziol * Programmer: Quincey Koziol
* koziol@hdfgroup.org * koziol@hdfgroup.org
@ -611,7 +611,7 @@ H5G_dense_lookup_by_idx_bt2_cb(const void *_record, void *_bt2_udata)
const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record;
H5G_bt2_ud_lbi_t *bt2_udata = (H5G_bt2_ud_lbi_t *)_bt2_udata; /* User data for callback */ H5G_bt2_ud_lbi_t *bt2_udata = (H5G_bt2_ud_lbi_t *)_bt2_udata; /* User data for callback */
H5G_fh_ud_lbi_t fh_udata; /* User data for fractal heap 'op' callback */ H5G_fh_ud_lbi_t fh_udata; /* User data for fractal heap 'op' callback */
int ret_value = H5B2_ITER_CONT; /* Return value */ int ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_dense_lookup_by_idx_bt2_cb) FUNC_ENTER_NOAPI_NOINIT(H5G_dense_lookup_by_idx_bt2_cb)
@ -624,7 +624,7 @@ H5G_dense_lookup_by_idx_bt2_cb(const void *_record, void *_bt2_udata)
/* Call fractal heap 'op' routine, to copy the link information */ /* Call fractal heap 'op' routine, to copy the link information */
if(H5HF_op(bt2_udata->fheap, bt2_udata->dxpl_id, record->id, if(H5HF_op(bt2_udata->fheap, bt2_udata->dxpl_id, record->id,
H5G_dense_lookup_by_idx_fh_cb, &fh_udata) < 0) H5G_dense_lookup_by_idx_fh_cb, &fh_udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, H5B2_ITER_ERROR, "link found callback failed") HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, H5_ITER_ERROR, "link found callback failed")
done: done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
@ -718,7 +718,7 @@ H5G_dense_lookup_by_idx(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
/* Copy link information */ /* Copy link information */
if(NULL == H5O_copy(H5O_LINK_ID, &ltable.lnks[n], lnk)) if(NULL == H5O_copy(H5O_LINK_ID, &ltable.lnks[n], lnk))
HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5B2_ITER_ERROR, "can't copy link message") HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message")
} /* end else */ } /* end else */
done: done:
@ -751,7 +751,7 @@ static herr_t
H5G_dense_build_table_cb(const H5O_link_t *lnk, void *_udata) H5G_dense_build_table_cb(const H5O_link_t *lnk, void *_udata)
{ {
H5G_dense_bt_ud_t *udata = (H5G_dense_bt_ud_t *)_udata; /* 'User data' passed in */ H5G_dense_bt_ud_t *udata = (H5G_dense_bt_ud_t *)_udata; /* 'User data' passed in */
herr_t ret_value = H5B2_ITER_CONT; /* Return value */ herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_dense_build_table_cb) FUNC_ENTER_NOAPI_NOINIT(H5G_dense_build_table_cb)
@ -762,7 +762,7 @@ H5G_dense_build_table_cb(const H5O_link_t *lnk, void *_udata)
/* Copy link information */ /* Copy link information */
if(H5O_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk])) == NULL) if(H5O_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk])) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5B2_ITER_ERROR, "can't copy link message") HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message")
/* Increment number of links stored */ /* Increment number of links stored */
udata->curr_lnk++; udata->curr_lnk++;
@ -828,23 +828,8 @@ H5G_dense_build_table(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over links") HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "error iterating over links")
/* Sort link table in correct iteration order */ /* Sort link table in correct iteration order */
if(idx_type == H5L_INDEX_NAME) { if(H5G_link_sort_table(ltable, idx_type, order) < 0)
if(order == H5_ITER_INC) HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting link messages")
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 */ } /* end if */
else else
ltable->lnks = NULL; ltable->lnks = NULL;
@ -896,7 +881,7 @@ done:
* *
* Purpose: v2 B-tree callback for dense link storage iterator * Purpose: v2 B-tree callback for dense link storage iterator
* *
* Return: H5B2_ITER_ERROR/H5B2_ITER_CONT/H5B2_ITER_STOP * Return: H5_ITER_ERROR/H5_ITER_CONT/H5_ITER_STOP
* *
* Programmer: Quincey Koziol * Programmer: Quincey Koziol
* koziol@hdfgroup.org * koziol@hdfgroup.org
@ -909,7 +894,7 @@ H5G_dense_iterate_bt2_cb(const void *_record, void *_bt2_udata)
{ {
const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record;
H5G_bt2_ud_it_t *bt2_udata = (H5G_bt2_ud_it_t *)_bt2_udata; /* User data for callback */ H5G_bt2_ud_it_t *bt2_udata = (H5G_bt2_ud_it_t *)_bt2_udata; /* User data for callback */
int ret_value = H5B2_ITER_CONT; /* Return value */ int ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_dense_iterate_bt2_cb) FUNC_ENTER_NOAPI_NOINIT(H5G_dense_iterate_bt2_cb)
@ -927,7 +912,7 @@ H5G_dense_iterate_bt2_cb(const void *_record, void *_bt2_udata)
/* Call fractal heap 'op' routine, to copy the link information */ /* Call fractal heap 'op' routine, to copy the link information */
if(H5HF_op(bt2_udata->fheap, bt2_udata->dxpl_id, record->id, if(H5HF_op(bt2_udata->fheap, bt2_udata->dxpl_id, record->id,
H5G_dense_iterate_fh_cb, &fh_udata) < 0) H5G_dense_iterate_fh_cb, &fh_udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, H5B2_ITER_ERROR, "link found callback failed") HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, H5_ITER_ERROR, "link found callback failed")
/* Check which type of callback to make */ /* Check which type of callback to make */
switch(bt2_udata->lnk_op->op_type) { switch(bt2_udata->lnk_op->op_type) {
@ -942,7 +927,7 @@ H5G_dense_iterate_bt2_cb(const void *_record, void *_bt2_udata)
/* Retrieve the info for the link */ /* Retrieve the info for the link */
if(H5G_link_to_info(fh_udata.lnk, &info) < 0) if(H5G_link_to_info(fh_udata.lnk, &info) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B2_ITER_ERROR, "unable to get info for link") HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get info for link")
/* Make the application callback */ /* Make the application callback */
ret_value = (bt2_udata->lnk_op->u.app_op)(bt2_udata->gid, fh_udata.lnk->name, &info, bt2_udata->op_data); ret_value = (bt2_udata->lnk_op->u.app_op)(bt2_udata->gid, fh_udata.lnk->name, &info, bt2_udata->op_data);
@ -990,10 +975,10 @@ 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, 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) hid_t gid, H5G_link_iterate_t *lnk_op, void *op_data)
{ {
H5G_bt2_ud_it_t udata; /* User data for iterator callback */ H5G_bt2_ud_it_t udata; /* User data for iterator callback */
H5HF_t *fheap = NULL; /* Fractal heap handle */ H5HF_t *fheap = NULL; /* Fractal heap handle */
H5G_link_table_t ltable = {0, NULL}; /* Table of links */ H5G_link_table_t ltable = {0, NULL}; /* Table of links */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_dense_iterate, FAIL) FUNC_ENTER_NOAPI(H5G_dense_iterate, FAIL)
@ -1028,51 +1013,12 @@ H5G_dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo,
HERROR(H5E_SYM, H5E_BADITER, "link iteration failed"); HERROR(H5E_SYM, H5E_BADITER, "link iteration failed");
} /* end if */ } /* end if */
else { else {
size_t u; /* Local index variable */
/* Build the table of links for this group */ /* Build the table of links for this group */
if(H5G_dense_build_table(f, dxpl_id, linfo, idx_type, order, &ltable) < 0) if(H5G_dense_build_table(f, dxpl_id, linfo, idx_type, order, &ltable) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "error building table of links") HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "error building table of links")
/* Iterate over link messages */ /* Iterate over links in table */
for(u = 0, ret_value = H5B_ITER_CONT; u < ltable.nlinks && !ret_value; u++) { if((ret_value = H5G_link_iterate_table(&ltable, skip, last_lnk, gid, lnk_op, op_data)) < 0)
if(skip > 0)
--skip;
else {
/* Check which kind of callback to make */
switch(lnk_op->op_type) {
case H5G_LINK_OP_OLD:
/* Make the old-type application callback */
ret_value = (lnk_op->u.old_op)(gid, ltable.lnks[u].name, op_data);
break;
case H5G_LINK_OP_APP:
{
H5L_info_t info; /* Link info */
/* Retrieve the info for the link */
if(H5G_link_to_info(&(ltable.lnks[u]), &info) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B2_ITER_ERROR, "unable to get info for link")
/* Make the application callback */
ret_value = (lnk_op->u.app_op)(gid, ltable.lnks[u].name, &info, op_data);
}
break;
case H5G_LINK_OP_LIB:
/* Call the library's callback */
ret_value = (lnk_op->u.lib_op)(&(ltable.lnks[u]), op_data);
} /* end switch */
} /* end else */
/* Increment the number of entries passed through */
/* (whether we skipped them or not) */
if(last_lnk)
(*last_lnk)++;
} /* end for */
/* Check for callback failure and pass along return value */
if(ret_value < 0)
HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed");
} /* end else */ } /* end else */
@ -1381,7 +1327,7 @@ H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata)
/* Decode link information */ /* Decode link information */
if(NULL == (lnk = H5O_decode(udata->f, udata->dxpl_id, obj, H5O_LINK_ID))) if(NULL == (lnk = H5O_decode(udata->f, udata->dxpl_id, obj, H5O_LINK_ID)))
HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, H5B2_ITER_ERROR, "can't decode link") HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, H5_ITER_ERROR, "can't decode link")
/* Check for removing the link from the creation order index */ /* Check for removing the link from the creation order index */
if(udata->rem_from_corder_index) { if(udata->rem_from_corder_index) {
@ -1395,7 +1341,7 @@ H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata)
HDassert(H5F_addr_defined(udata->corder_bt2_addr)); HDassert(H5F_addr_defined(udata->corder_bt2_addr));
if(H5B2_remove(udata->f, udata->dxpl_id, H5G_BT2_CORDER, udata->corder_bt2_addr, if(H5B2_remove(udata->f, udata->dxpl_id, H5G_BT2_CORDER, udata->corder_bt2_addr,
&bt2_udata, NULL, NULL) < 0) &bt2_udata, NULL, NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, H5B2_ITER_ERROR, "unable to remove link from creation order index v2 B-tree") HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, H5_ITER_ERROR, "unable to remove link from creation order index v2 B-tree")
} /* end if */ } /* end if */
/* Replace open objects' names, if requested */ /* Replace open objects' names, if requested */
@ -1550,7 +1496,7 @@ H5G_dense_remove_by_idx_fh_cb(const void *obj, size_t UNUSED obj_len, void *_uda
/* Decode link information */ /* Decode link information */
if(NULL == (udata->lnk = H5O_decode(udata->f, udata->dxpl_id, obj, H5O_LINK_ID))) if(NULL == (udata->lnk = H5O_decode(udata->f, udata->dxpl_id, obj, H5O_LINK_ID)))
HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, H5B2_ITER_ERROR, "can't decode link") HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, H5_ITER_ERROR, "can't decode link")
/* Can't operate on link here because the fractal heap block is locked */ /* Can't operate on link here because the fractal heap block is locked */
@ -1643,7 +1589,7 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata)
/* Remove the record from the name index v2 B-tree */ /* Remove the record from the name index v2 B-tree */
if(H5B2_remove(bt2_udata->f, bt2_udata->dxpl_id, other_bt2_class, bt2_udata->other_bt2_addr, if(H5B2_remove(bt2_udata->f, bt2_udata->dxpl_id, other_bt2_class, bt2_udata->other_bt2_addr,
&other_bt2_udata, NULL, NULL) < 0) &other_bt2_udata, NULL, NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, H5B2_ITER_ERROR, "unable to remove link from creation order index v2 B-tree") HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, H5_ITER_ERROR, "unable to remove link from creation order index v2 B-tree")
} /* end if */ } /* end if */
/* Replace open objects' names */ /* Replace open objects' names */

View File

@ -675,3 +675,74 @@ done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_get_comment() */ } /* end H5G_get_comment() */
/*-------------------------------------------------------------------------
* Function: H5Giterate
*
* Purpose: Iterates over the entries of a group. The LOC_ID and NAME
* identify the group over which to iterate and IDX indicates
* where to start iterating (zero means at the beginning). The
* OPERATOR is called for each member and the iteration
* continues until the operator returns non-zero or all members
* are processed. The operator is passed a group ID for the
* group being iterated, a member name, and OP_DATA for each
* member.
*
* Return: Success: The return value of the first operator that
* returns non-zero, or zero if all members were
* processed with no operator returning non-zero.
*
* Failure: Negative if something goes wrong within the
* library, or the negative value returned by one
* of the operators.
*
* Programmer: Robb Matzke
* Monday, March 23, 1998
*
*-------------------------------------------------------------------------
*/
herr_t
H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op,
void *op_data)
{
H5G_link_iterate_t lnk_op; /* Link operator */
hsize_t last_obj; /* Index of last object looked at */
hsize_t idx; /* Internal location to hold index */
herr_t ret_value;
FUNC_ENTER_API(H5Giterate, FAIL)
H5TRACE5("e","is*Isxx",loc_id,name,idx_p,op,op_data);
/* Check args */
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
if(idx_p && *idx_p < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified")
if(!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified")
/* Set number of objects looked at to zero */
last_obj = 0;
idx = (hsize_t)(idx_p == NULL ? 0 : *idx_p);
/* Build link operator info */
lnk_op.op_type = H5G_LINK_OP_OLD;
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)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed")
/* Check for too high of a starting index (ex post facto :-) */
/* (Skipping exactly as many entries as are in the group is currently an error) */
if(idx > 0 && idx >= last_obj)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified")
/* Set the index we stopped at */
if(idx_p)
*idx_p = (int)last_obj;
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Giterate() */

View File

@ -217,7 +217,7 @@ H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2)
*/ */
herr_t herr_t
H5G_ent_to_link(H5F_t *f, hid_t dxpl_id, H5O_link_t *lnk, haddr_t lheap_addr, H5G_ent_to_link(H5F_t *f, hid_t dxpl_id, H5O_link_t *lnk, haddr_t lheap_addr,
const H5G_entry_t *ent, const char *name) H5HL_t *_heap, const H5G_entry_t *ent, const char *name)
{ {
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
@ -226,31 +226,39 @@ H5G_ent_to_link(H5F_t *f, hid_t dxpl_id, H5O_link_t *lnk, haddr_t lheap_addr,
/* check arguments */ /* check arguments */
HDassert(f); HDassert(f);
HDassert(lnk); HDassert(lnk);
HDassert(H5F_addr_defined(lheap_addr) || _heap);
HDassert(!(H5F_addr_defined(lheap_addr) && _heap));
HDassert(ent); HDassert(ent);
HDassert(name);
/* Set (default) common info for link */ /* Set (default) common info for link */
lnk->cset = H5F_DEFAULT_CSET; lnk->cset = H5F_DEFAULT_CSET;
lnk->corder = 0; lnk->corder = 0;
lnk->corder_valid = FALSE; /* Creation order not valid for this link */ lnk->corder_valid = FALSE; /* Creation order not valid for this link */
lnk->name = H5MM_xstrdup(name); lnk->name = H5MM_xstrdup(name);
HDassert(lnk->name);
/* Object is a symbolic or hard link */ /* Object is a symbolic or hard link */
if(ent->type == H5G_CACHED_SLINK) { if(ent->type == H5G_CACHED_SLINK) {
const char *s; /* Pointer to link value */ const char *s; /* Pointer to link value */
H5HL_t *heap; /* Pointer to local heap for group */ H5HL_t *heap = _heap; /* Pointer to local heap for group */
/* Lock the local heap */ /* Check if the heap pointer was passed in */
if(NULL == (heap = H5HL_protect(f, dxpl_id, lheap_addr))) if(!heap) {
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read protect link value") /* Lock the local heap */
if(NULL == (heap = H5HL_protect(f, dxpl_id, lheap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect local heap")
} /* end if */
s = H5HL_offset_into(f, heap, ent->cache.slink.lval_offset); s = H5HL_offset_into(f, heap, ent->cache.slink.lval_offset);
/* Copy the link value */ /* Copy the link value */
lnk->u.soft.name = H5MM_xstrdup(s); lnk->u.soft.name = H5MM_xstrdup(s);
/* Release the local heap */ /* Release the local heap, if we locked it */
if(H5HL_unprotect(f, dxpl_id, heap, lheap_addr, H5AC__NO_FLAGS_SET) < 0) if(heap != _heap)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read unprotect link value") if(H5HL_unprotect(f, dxpl_id, heap, lheap_addr, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read unprotect link value")
/* Set link type */ /* Set link type */
lnk->type = H5L_TYPE_SOFT; lnk->type = H5L_TYPE_SOFT;
@ -330,7 +338,7 @@ H5G_ent_to_info(H5F_t *f, hid_t dxpl_id, H5L_info_t *info, haddr_t lheap_addr,
done: done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_ent_to_link() */ } /* end H5G_ent_to_info() */
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
@ -445,7 +453,7 @@ H5G_link_copy_file(H5F_t *dst_file, hid_t dxpl_id, const H5O_link_t *_src_lnk,
/* Make a temporary copy, so that it will not change the info in the cache */ /* Make a temporary copy, so that it will not change the info in the cache */
if(NULL == H5O_copy(H5O_LINK_ID, src_lnk, &tmp_src_lnk)) if(NULL == H5O_copy(H5O_LINK_ID, src_lnk, &tmp_src_lnk))
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5B2_ITER_ERROR, "unable to copy message") HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy message")
/* Set up group location for soft link to start in */ /* Set up group location for soft link to start in */
H5G_name_reset(&grp_path); H5G_name_reset(&grp_path);
@ -478,7 +486,7 @@ H5G_link_copy_file(H5F_t *dst_file, hid_t dxpl_id, const H5O_link_t *_src_lnk,
/* Copy src link information to dst link information */ /* Copy src link information to dst link information */
if(NULL == H5O_copy(H5O_LINK_ID, src_lnk, dst_lnk)) if(NULL == H5O_copy(H5O_LINK_ID, src_lnk, dst_lnk))
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5B2_ITER_ERROR, "unable to copy message") HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy message")
dst_lnk_init = TRUE; dst_lnk_init = TRUE;
/* Check if object in source group is a hard link & copy it */ /* Check if object in source group is a hard link & copy it */
@ -498,7 +506,7 @@ H5G_link_copy_file(H5F_t *dst_file, hid_t dxpl_id, const H5O_link_t *_src_lnk,
/* Copy the shared object from source to destination */ /* Copy the shared object from source to destination */
if(H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, dxpl_id, cpy_info, TRUE) < 0) if(H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, dxpl_id, cpy_info, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5B2_ITER_ERROR, "unable to copy object") HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy object")
/* Copy new destination object's information for eventual insertion */ /* Copy new destination object's information for eventual insertion */
dst_lnk->u.hard.addr = new_dst_oloc.addr; dst_lnk->u.hard.addr = new_dst_oloc.addr;
@ -517,6 +525,124 @@ done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_link_copy_file() */ } /* end H5G_link_copy_file() */
/*-------------------------------------------------------------------------
* Function: H5G_link_sort_table
*
* Purpose: Sort table containing a list of links for a group
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Nov 20, 2006
*
*-------------------------------------------------------------------------
*/
herr_t
H5G_link_sort_table(H5G_link_table_t *ltable, H5L_index_t idx_type,
H5_iter_order_t order)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_link_sort_table)
/* Sanity check */
HDassert(ltable);
/* Pick appropriate sorting routine */
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 */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5G_link_sort_table() */
/*-------------------------------------------------------------------------
* Function: H5G_link_iterate_table
*
* Purpose: Iterate over table containing a list of links for a group,
* making appropriate callbacks
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Nov 20, 2006
*
*-------------------------------------------------------------------------
*/
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)
{
size_t u; /* Local index variable */
herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI(H5G_link_iterate_table, FAIL)
/* Sanity check */
HDassert(ltable);
HDassert(lnk_op);
/* Skip over links, if requested */
if(last_lnk)
*last_lnk += skip;
/* Iterate over link messages */
H5_ASSIGN_OVERFLOW(/* To: */ u, /* From: */ skip, /* From: */ hsize_t, /* To: */ size_t)
for(; u < ltable->nlinks && !ret_value; u++) {
/* Check which kind of callback to make */
switch(lnk_op->op_type) {
case H5G_LINK_OP_OLD:
/* Make the old-type application callback */
ret_value = (lnk_op->u.old_op)(gid, ltable->lnks[u].name, op_data);
break;
case H5G_LINK_OP_APP:
{
H5L_info_t info; /* Link info */
/* Retrieve the info for the link */
if(H5G_link_to_info(&(ltable->lnks[u]), &info) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get info for link")
/* Make the application callback */
ret_value = (lnk_op->u.app_op)(gid, ltable->lnks[u].name, &info, op_data);
}
break;
case H5G_LINK_OP_LIB:
/* Call the library's callback */
ret_value = (lnk_op->u.lib_op)(&(ltable->lnks[u]), op_data);
} /* end switch */
/* Increment the number of entries passed through */
if(last_lnk)
(*last_lnk)++;
} /* end for */
/* Check for callback failure and pass along return value */
if(ret_value < 0)
HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed");
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_link_iterate_table() */
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function: H5G_link_release_table * Function: H5G_link_release_table

View File

@ -267,7 +267,7 @@ H5G_node_debug_key(FILE *stream, H5F_t *f, hid_t dxpl_id, int indent, int fwidth
const void *_key, const void *_udata) const void *_key, const void *_udata)
{ {
const H5G_node_key_t *key = (const H5G_node_key_t *) _key; const H5G_node_key_t *key = (const H5G_node_key_t *) _key;
const H5G_bt_ud0_t *udata = (const H5G_bt_ud0_t *) _udata; const H5G_bt_common_t *udata = (const H5G_bt_common_t *) _udata;
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_node_debug_key) FUNC_ENTER_NOAPI_NOINIT(H5G_node_debug_key)
@ -778,7 +778,7 @@ done:
static int static int
H5G_node_cmp2(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, void *_rt_key) H5G_node_cmp2(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, void *_rt_key)
{ {
H5G_bt_ud0_t *udata = (H5G_bt_ud0_t *) _udata; H5G_bt_common_t *udata = (H5G_bt_common_t *) _udata;
H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key; H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key;
H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key;
H5HL_t *heap = NULL; H5HL_t *heap = NULL;
@ -843,7 +843,7 @@ done:
static int static int
H5G_node_cmp3(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, void *_rt_key) H5G_node_cmp3(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, void *_rt_key)
{ {
H5G_bt_ud0_t *udata = (H5G_bt_ud0_t *) _udata; H5G_bt_common_t *udata = (H5G_bt_common_t *) _udata;
H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key; H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key;
H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key;
H5HL_t *heap = NULL; H5HL_t *heap = NULL;
@ -907,7 +907,7 @@ static herr_t
H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key, H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key,
void *_udata) void *_udata)
{ {
H5G_bt_ud3_t *udata = (H5G_bt_ud3_t *) _udata; H5G_bt_lkp_t *udata = (H5G_bt_lkp_t *) _udata;
H5G_node_t *sn = NULL; H5G_node_t *sn = NULL;
H5HL_t *heap = NULL; H5HL_t *heap = NULL;
unsigned lt = 0, idx = 0, rt; unsigned lt = 0, idx = 0, rt;
@ -1014,7 +1014,7 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr,
{ {
H5G_node_key_t *md_key = (H5G_node_key_t *) _md_key; H5G_node_key_t *md_key = (H5G_node_key_t *) _md_key;
H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key;
H5G_bt_ud1_t *udata = (H5G_bt_ud1_t *) _udata; H5G_bt_ins_t *udata = (H5G_bt_ins_t *) _udata;
H5G_node_t *sn = NULL, *snrt = NULL; H5G_node_t *sn = NULL, *snrt = NULL;
unsigned sn_flags = H5AC__NO_FLAGS_SET, snrt_flags = H5AC__NO_FLAGS_SET; unsigned sn_flags = H5AC__NO_FLAGS_SET, snrt_flags = H5AC__NO_FLAGS_SET;
H5HL_t *heap = NULL; H5HL_t *heap = NULL;
@ -1196,7 +1196,7 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/,
{ {
H5G_node_key_t *lt_key = (H5G_node_key_t *)_lt_key; H5G_node_key_t *lt_key = (H5G_node_key_t *)_lt_key;
H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key;
H5G_bt_ud2_t *udata = (H5G_bt_ud2_t *)_udata; H5G_bt_rm_t *udata = (H5G_bt_rm_t *)_udata;
H5G_node_t *sn = NULL; H5G_node_t *sn = NULL;
unsigned sn_flags = H5AC__NO_FLAGS_SET; unsigned sn_flags = H5AC__NO_FLAGS_SET;
H5HL_t *heap = NULL; H5HL_t *heap = NULL;
@ -1416,15 +1416,17 @@ int
H5G_node_iterate(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, H5G_node_iterate(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr,
const void UNUSED *_rt_key, void *_udata) const void UNUSED *_rt_key, void *_udata)
{ {
H5G_bt_it_ud1_t *udata = (H5G_bt_it_ud1_t *)_udata; H5G_bt_it_it_t *udata = (H5G_bt_it_it_t *)_udata;
H5G_node_t *sn = NULL; H5G_node_t *sn = NULL;
H5HL_t *heap = NULL; H5HL_t *heap = NULL;
char buf[1024], *s = buf; /* Buffer for link name & pointer to link name */
size_t buf_size = sizeof(buf); /* Size of link name buffer */
unsigned nsyms; /* # of symbols in node */ unsigned nsyms; /* # of symbols in node */
H5G_entry_t *ents = NULL; /* Copy of entries in this node */ H5G_entry_t *ents = NULL; /* Copy of entries in this node */
unsigned u; /* Local index variable */ unsigned u; /* Local index variable */
int ret_value; int ret_value;
FUNC_ENTER_NOAPI(H5G_node_iterate, H5B_ITER_ERROR) FUNC_ENTER_NOAPI(H5G_node_iterate, H5_ITER_ERROR)
/* /*
* Check arguments. * Check arguments.
@ -1438,31 +1440,30 @@ H5G_node_iterate(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t ad
* because we're about to call an application function. * because we're about to call an application function.
*/ */
if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ)))
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node") HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node")
nsyms = sn->nsyms; nsyms = sn->nsyms;
if(NULL == (ents = H5FL_SEQ_MALLOC(H5G_entry_t, (size_t)nsyms))) if(NULL == (ents = H5FL_SEQ_MALLOC(H5G_entry_t, (size_t)nsyms)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5B_ITER_ERROR, "memory allocation failed") HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed")
HDmemcpy(ents, sn->entry, sizeof(H5G_entry_t) * nsyms); HDmemcpy(ents, sn->entry, sizeof(H5G_entry_t) * nsyms);
if(H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) != SUCCEED) { if(H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) != SUCCEED) {
sn = NULL; sn = NULL;
HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header") HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header")
} /* end if */ } /* end if */
sn = NULL; /* Make certain future references will be caught */ sn = NULL; /* Make certain future references will be caught */
/* /*
* Iterate over the symbol table node entries. * Iterate over the symbol table node entries.
*/ */
for(u = 0, ret_value = H5B_ITER_CONT; u < nsyms && !ret_value; u++) { for(u = 0, ret_value = H5_ITER_CONT; u < nsyms && !ret_value; u++) {
if(udata->skip > 0) if(udata->skip > 0)
--udata->skip; --udata->skip;
else { else {
size_t n; /* Length of link name */ size_t n; /* Length of link name */
const char *name; /* Pointer to link name in heap */ const char *name; /* Pointer to link name in heap */
char buf[1024], *s; /* Buffer for link name & pointer to link name */
if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->heap_addr))) if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->heap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_ITER_ERROR, "unable to protect symbol name") HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "unable to protect symbol name")
name = H5HL_offset_into(f, heap, ents[u].name_off); name = H5HL_offset_into(f, heap, ents[u].name_off);
HDassert(name); HDassert(name);
@ -1470,8 +1471,11 @@ H5G_node_iterate(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t ad
/* Allocate space or point to existing buffer */ /* Allocate space or point to existing buffer */
if((n + 1) > sizeof(buf)) { if((n + 1) > sizeof(buf)) {
if(s != buf)
H5MM_xfree(s);
if(NULL == (s = H5MM_malloc(n + 1))) if(NULL == (s = H5MM_malloc(n + 1)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5B_ITER_ERROR, "memory allocation failed") HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed")
buf_size = n + 1;
} /* end if */ } /* end if */
else else
s = buf; s = buf;
@ -1480,7 +1484,7 @@ H5G_node_iterate(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t ad
HDstrcpy(s, name); HDstrcpy(s, name);
if(H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0) if(H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to unprotect symbol name") HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to unprotect symbol name")
heap = NULL; name = NULL; heap = NULL; name = NULL;
/* Check which type of callback to make */ /* Check which type of callback to make */
@ -1496,11 +1500,11 @@ H5G_node_iterate(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t ad
/* Make a link info for an entry */ /* Make a link info for an entry */
if(H5G_ent_to_info(f, dxpl_id, &info, udata->heap_addr, &ents[u]) < 0) if(H5G_ent_to_info(f, dxpl_id, &info, udata->heap_addr, &ents[u]) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_ITER_ERROR, "unable to get info for symbol table entry") HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get info for symbol table entry")
/* Make the application callback */ /* Make the application callback */
ret_value = (udata->lnk_op->u.app_op)(udata->group_id, s, &info, udata->op_data); ret_value = (udata->lnk_op->u.app_op)(udata->group_id, s, &info, udata->op_data);
} /* end if */ }
break; break;
case H5G_LINK_OP_LIB: case H5G_LINK_OP_LIB:
@ -1509,21 +1513,17 @@ H5G_node_iterate(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t ad
H5O_link_t lnk; /* Link for entry */ H5O_link_t lnk; /* Link for entry */
/* Convert the entry to a link */ /* Convert the entry to a link */
if(H5G_ent_to_link(f, dxpl_id, &lnk, udata->heap_addr, &ents[u], s) < 0) if(H5G_ent_to_link(f, dxpl_id, &lnk, udata->heap_addr, NULL, &ents[u], s) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5B_ITER_ERROR, "unable to convert symbol table entry to link") HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, "unable to convert symbol table entry to link")
/* Call the library's callback */ /* Call the library's callback */
ret_value = (udata->lnk_op->u.lib_op)(&lnk, udata->op_data); ret_value = (udata->lnk_op->u.lib_op)(&lnk, udata->op_data);
/* Release memory for link object */ /* Release memory for link object */
if(H5O_reset(H5O_LINK_ID, &lnk) < 0) if(H5O_reset(H5O_LINK_ID, &lnk) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, H5B_ITER_ERROR, "unable to release link message") HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, H5_ITER_ERROR, "unable to release link message")
} /* end if */ }
} /* end switch */ } /* end switch */
/* Free the memory for the name, if we used a dynamically allocated buffer */
if(s != buf)
H5MM_xfree(s);
} /* end else */ } /* end else */
/* Increment the number of entries passed through */ /* Increment the number of entries passed through */
@ -1535,11 +1535,15 @@ H5G_node_iterate(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t ad
HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed");
done: done:
/* Free the memory for the name, if we used a dynamically allocated buffer */
if(s != buf)
H5MM_xfree(s);
if(heap && H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0) if(heap && H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to unprotect symbol name") HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to unprotect symbol name")
if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) != SUCCEED) if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) != SUCCEED)
HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header") HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header")
if(ents) if(ents)
H5FL_SEQ_FREE(H5G_entry_t, ents); H5FL_SEQ_FREE(H5G_entry_t, ents);
@ -1567,9 +1571,9 @@ H5G_node_sumup(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr
{ {
hsize_t *num_objs = (hsize_t *)_udata; hsize_t *num_objs = (hsize_t *)_udata;
H5G_node_t *sn = NULL; H5G_node_t *sn = NULL;
int ret_value = H5B_ITER_CONT; int ret_value = H5_ITER_CONT;
FUNC_ENTER_NOAPI(H5G_node_sumup, H5B_ITER_ERROR) FUNC_ENTER_NOAPI(H5G_node_sumup, H5_ITER_ERROR)
/* /*
* Check arguments. * Check arguments.
@ -1580,13 +1584,13 @@ H5G_node_sumup(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr
/* Find the object node and add the number of symbol entries. */ /* Find the object node and add the number of symbol entries. */
if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ)))
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node") HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node")
*num_objs += sn->nsyms; *num_objs += sn->nsyms;
done: done:
if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) != SUCCEED) if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) != SUCCEED)
HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header") HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header")
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_node_sumup() */ } /* end H5G_node_sumup() */
@ -1612,9 +1616,9 @@ H5G_node_by_idx(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t add
{ {
H5G_bt_it_idx_common_t *udata = (H5G_bt_it_idx_common_t *)_udata; H5G_bt_it_idx_common_t *udata = (H5G_bt_it_idx_common_t *)_udata;
H5G_node_t *sn = NULL; H5G_node_t *sn = NULL;
int ret_value = H5B_ITER_CONT; int ret_value = H5_ITER_CONT;
FUNC_ENTER_NOAPI(H5G_node_by_idx, H5B_ITER_ERROR); FUNC_ENTER_NOAPI(H5G_node_by_idx, H5_ITER_ERROR);
/* /*
* Check arguments. * Check arguments.
@ -1625,7 +1629,7 @@ H5G_node_by_idx(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t add
/* Get a pointer to the symbol table node */ /* Get a pointer to the symbol table node */
if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ)))
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node"); HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node");
/* Find the node, locate the object symbol table entry and retrieve the name */ /* Find the node, locate the object symbol table entry and retrieve the name */
if(udata->idx >= udata->num_objs && udata->idx < (udata->num_objs + sn->nsyms)) { if(udata->idx >= udata->num_objs && udata->idx < (udata->num_objs + sn->nsyms)) {
@ -1640,14 +1644,14 @@ H5G_node_by_idx(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t add
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "'by index' callback failed") HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "'by index' callback failed")
/* Indicate that we found the entry we are interested in */ /* Indicate that we found the entry we are interested in */
ret_value = H5B_ITER_STOP; ret_value = H5_ITER_STOP;
} /* end if */ } /* end if */
else else
udata->num_objs += sn->nsyms; udata->num_objs += sn->nsyms;
done: done:
if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) != SUCCEED) if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) != SUCCEED)
HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header") HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header")
FUNC_LEAVE_NOAPI(ret_value); FUNC_LEAVE_NOAPI(ret_value);
} /* end H5G_node_by_idx() */ } /* end H5G_node_by_idx() */
@ -1799,9 +1803,9 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr,
H5HL_t *heap = NULL; H5HL_t *heap = NULL;
H5G_node_t *sn = NULL; H5G_node_t *sn = NULL;
unsigned int i; /* Local index variable */ unsigned int i; /* Local index variable */
int ret_value = H5B_ITER_CONT; int ret_value = H5_ITER_CONT;
FUNC_ENTER_NOAPI(H5G_node_copy, H5B_ITER_ERROR) FUNC_ENTER_NOAPI(H5G_node_copy, H5_ITER_ERROR)
/* Check arguments. */ /* Check arguments. */
HDassert(f); HDassert(f);
@ -1810,11 +1814,11 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr,
/* load the symbol table into memory from the source file */ /* load the symbol table into memory from the source file */
if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ)))
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node") HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node")
/* get the base address of the heap */ /* get the base address of the heap */
if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->src_heap_addr))) if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->src_heap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_ITER_ERROR, "unable to protect symbol name") HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "unable to protect symbol name")
/* copy object in this node one by one */ /* copy object in this node one by one */
for(i = 0; i < sn->nsyms; i++) { for(i = 0; i < sn->nsyms; i++) {
@ -1873,7 +1877,7 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr,
/* Copy the shared object from source to destination */ /* Copy the shared object from source to destination */
if(H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, dxpl_id, cpy_info, TRUE) < 0) if(H5O_copy_header_map(&tmp_src_oloc, &new_dst_oloc, dxpl_id, cpy_info, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5B_ITER_ERROR, "unable to copy object") HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy object")
/* Construct link information for eventual insertion */ /* Construct link information for eventual insertion */
lnk.type = H5L_TYPE_HARD; lnk.type = H5L_TYPE_HARD;
@ -1902,19 +1906,101 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr,
/* Insert the new object in the destination file's group */ /* Insert the new object in the destination file's group */
/* (Don't increment the link count - that's already done above for hard links) */ /* (Don't increment the link count - that's already done above for hard links) */
if(H5G_stab_insert_real(udata->dst_file, udata->dst_stab, name, &lnk, dxpl_id) < 0) if(H5G_stab_insert_real(udata->dst_file, udata->dst_stab, name, &lnk, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5B_ITER_ERROR, "unable to insert the name") HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "unable to insert the name")
} /* end of for (i=0; i<sn->nsyms; i++) */ } /* end of for (i=0; i<sn->nsyms; i++) */
done: done:
if (heap && H5HL_unprotect(f, dxpl_id, heap, udata->src_heap_addr, H5AC__NO_FLAGS_SET) < 0) if (heap && H5HL_unprotect(f, dxpl_id, heap, udata->src_heap_addr, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to unprotect symbol name") HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to unprotect symbol name")
if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) != SUCCEED) if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) != SUCCEED)
HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header") HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header")
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_node_copy() */ } /* end H5G_node_copy() */
/*-------------------------------------------------------------------------
* Function: H5G_node_build_table
*
* Purpose: B-link tree callback for building table of links
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* koziol@hdfgroup.org
* Nov 19 2006
*
*-------------------------------------------------------------------------
*/
int
H5G_node_build_table(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr,
const void UNUSED *_rt_key, void *_udata)
{
H5G_bt_it_bt_t *udata = (H5G_bt_it_bt_t *)_udata;
H5G_node_t *sn = NULL; /* Symbol table node */
H5HL_t *heap = NULL; /* Local heap for group */
unsigned u; /* Local index variable */
int ret_value = H5_ITER_CONT;
FUNC_ENTER_NOAPI(H5G_node_build_table, H5_ITER_ERROR)
/*
* Check arguments.
*/
HDassert(f);
HDassert(H5F_addr_defined(addr));
HDassert(udata);
/*
* Save information about the symbol table node since we can't lock it
* because we're about to call an application function.
*/
if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ)))
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load symbol table node")
/* Lock down the heap for this group */
if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->heap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "unable to protect symbol name")
/* Check if the link table needs to be extended */
if((udata->ltable->nlinks + sn->nsyms) >= udata->alloc_nlinks) {
size_t na = MAX((udata->ltable->nlinks + sn->nsyms), (udata->alloc_nlinks * 2)); /* Double # of links allocated */
H5O_link_t *x; /* Pointer to larger array of links */
/* Re-allocate the link table */
if((x = H5MM_realloc(udata->ltable->lnks, sizeof(H5O_link_t) * na)) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed")
udata->ltable->lnks = x;
} /* end if */
/* Iterate over the symbol table node entries, adding to link table */
for(u = 0; u < sn->nsyms; u++) {
const char *name; /* Pointer to link name in heap */
unsigned linkno; /* Link allocated */
/* Get pointer to link's name in the heap */
name = H5HL_offset_into(f, heap, sn->entry[u].name_off);
HDassert(name);
/* Determine the link to operate on in the table */
linkno = udata->ltable->nlinks++;
/* Convert the entry to a link */
if(H5G_ent_to_link(f, dxpl_id, &udata->ltable->lnks[linkno], HADDR_UNDEF, heap, &sn->entry[u], name) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, "unable to convert symbol table entry to link")
} /* end for */
done:
/* Release the locked items */
if(heap && H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to unprotect symbol name")
if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) != SUCCEED)
HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5_ITER_ERROR, "unable to release object header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_node_build_table() */
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function: H5G_node_debug * Function: H5G_node_debug
@ -1956,7 +2042,7 @@ H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent,
* B-tree node. * B-tree node.
*/ */
if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) { if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) {
H5G_bt_ud0_t udata; /*data to pass through B-tree */ H5G_bt_common_t udata; /*data to pass through B-tree */
H5E_clear_stack(NULL); /* discard that error */ H5E_clear_stack(NULL); /* discard that error */
udata.heap_addr = heap_addr; udata.heap_addr = heap_addr;

View File

@ -324,7 +324,7 @@ 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 */ 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 */ 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 */ herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_obj_compact_to_dense_cb) FUNC_ENTER_NOAPI_NOINIT(H5G_obj_compact_to_dense_cb)
@ -359,7 +359,7 @@ static herr_t
H5G_obj_stab_to_new_cb(const H5O_link_t *lnk, void *_udata) H5G_obj_stab_to_new_cb(const H5O_link_t *lnk, void *_udata)
{ {
H5G_obj_stab_it_ud1_t *udata = (H5G_obj_stab_it_ud1_t *)_udata; /* 'User data' passed in */ H5G_obj_stab_it_ud1_t *udata = (H5G_obj_stab_it_ud1_t *)_udata; /* 'User data' passed in */
herr_t ret_value = H5B_ITER_CONT; /* Return value */ herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_obj_stab_to_new_cb) FUNC_ENTER_NOAPI_NOINIT(H5G_obj_stab_to_new_cb)
@ -370,7 +370,7 @@ H5G_obj_stab_to_new_cb(const H5O_link_t *lnk, void *_udata)
/* Insert link into group */ /* Insert link into group */
/* (Casting away const OK - QAK) */ /* (Casting away const OK - QAK) */
if(H5G_obj_insert(udata->grp_oloc, lnk->name, (H5O_link_t *)lnk, FALSE, udata->dxpl_id) < 0) if(H5G_obj_insert(udata->grp_oloc, lnk->name, (H5O_link_t *)lnk, FALSE, udata->dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_ITER_ERROR, "can't insert link into group") HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert link into group")
done: done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)

View File

@ -142,48 +142,46 @@ typedef struct {
} u; } u;
} H5G_link_iterate_t; } H5G_link_iterate_t;
/* Data structure to hold table of links for a group */
typedef struct {
size_t nlinks; /* # of links in table */
H5O_link_t *lnks; /* Pointer to array of links */
} H5G_link_table_t;
/* /*
* Common data exchange structure for symbol table nodes. This structure is * Common data exchange structure for symbol table nodes. This structure is
* passed through the B-link tree layer to the methods for the objects * passed through the B-link tree layer to the methods for the objects
* to which the B-link tree points. * to which the B-link tree points.
*
* It's also used for B-tree iterators which require no additional info.
*
*/ */
typedef struct H5G_bt_ud_common_t { typedef struct H5G_bt_common_t {
/* downward */ /* downward */
const char *name; /*points to temporary memory */ const char *name; /*points to temporary memory */
haddr_t heap_addr; /*symbol table heap address */ haddr_t heap_addr; /*symbol table heap address */
} H5G_bt_ud_common_t; } H5G_bt_common_t;
/*
* Data exchange structure for symbol table nodes. This structure is
* passed through the B-link tree layer to the methods for the objects
* to which the B-link tree points for operations which require no
* additional information.
*
* (Just an alias for the "common" info).
*/
typedef H5G_bt_ud_common_t H5G_bt_ud0_t;
/* /*
* Data exchange structure for symbol table nodes. This structure is * Data exchange structure for symbol table nodes. This structure is
* passed through the B-link tree layer to the insert method for entries. * passed through the B-link tree layer to the insert method for entries.
*/ */
typedef struct H5G_bt_ud1_t { typedef struct H5G_bt_ins_t {
/* downward */ /* downward */
H5G_bt_ud_common_t common; /* Common info for B-tree user data (must be first) */ H5G_bt_common_t common; /* Common info for B-tree user data (must be first) */
const H5O_link_t *lnk; /* Link to insert into table */ const H5O_link_t *lnk; /* Link to insert into table */
} H5G_bt_ud1_t; } H5G_bt_ins_t;
/* /*
* Data exchange structure for symbol table nodes. This structure is * Data exchange structure for symbol table nodes. This structure is
* passed through the B-link tree layer to the methods for the objects * passed through the B-link tree layer to the remove method for entries.
* to which the B-link tree points.
*/ */
typedef struct H5G_bt_ud2_t { typedef struct H5G_bt_rm_t {
/* downward */ /* downward */
H5G_bt_ud_common_t common; /* Common info for B-tree user data (must be first) */ H5G_bt_common_t common; /* Common info for B-tree user data (must be first) */
hbool_t adj_link; /* Whether to adjust the link count on objects */ hbool_t adj_link; /* Whether to adjust the link count on objects */
H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */
} H5G_bt_ud2_t; } H5G_bt_rm_t;
/* Typedef for B-tree 'find' operation */ /* Typedef for B-tree 'find' operation */
typedef herr_t (*H5G_bt_find_op_t)(const H5G_entry_t *ent/*in*/, void *operator_data/*in,out*/); typedef herr_t (*H5G_bt_find_op_t)(const H5G_entry_t *ent/*in*/, void *operator_data/*in,out*/);
@ -192,20 +190,20 @@ typedef herr_t (*H5G_bt_find_op_t)(const H5G_entry_t *ent/*in*/, void *operator_
* Data exchange structure for symbol table nodes. This structure is * Data exchange structure for symbol table nodes. This structure is
* passed through the B-link tree layer to the 'find' method for entries. * passed through the B-link tree layer to the 'find' method for entries.
*/ */
typedef struct H5G_bt_ud3_t { typedef struct H5G_bt_lkp_t {
/* downward */ /* downward */
H5G_bt_ud_common_t common; /* Common info for B-tree user data (must be first) */ H5G_bt_common_t common; /* Common info for B-tree user data (must be first) */
H5G_bt_find_op_t op; /* Operator to call when correct entry is found */ H5G_bt_find_op_t op; /* Operator to call when correct entry is found */
void *op_data; /* Data to pass to operator */ void *op_data; /* Data to pass to operator */
/* upward */ /* upward */
} H5G_bt_ud3_t; } H5G_bt_lkp_t;
/* /*
* Data exchange structure to pass through the B-tree layer for the * Data exchange structure to pass through the B-tree layer for the
* H5B_iterate function. * H5B_iterate function.
*/ */
typedef struct H5G_bt_it_ud1_t { typedef struct H5G_bt_it_it_t {
/* downward */ /* downward */
hid_t group_id; /*group id to pass to iteration operator */ hid_t group_id; /*group id to pass to iteration operator */
haddr_t heap_addr; /*symbol table heap address */ haddr_t heap_addr; /*symbol table heap address */
@ -215,7 +213,7 @@ typedef struct H5G_bt_it_ud1_t {
/* upward */ /* upward */
hsize_t *final_ent; /*final entry looked at */ hsize_t *final_ent; /*final entry looked at */
} H5G_bt_it_ud1_t; } H5G_bt_it_it_t;
/* Data passed through B-tree iteration for copying copy symbol table content */ /* Data passed through B-tree iteration for copying copy symbol table content */
typedef struct H5G_bt_it_cpy_t { typedef struct H5G_bt_it_cpy_t {
@ -237,26 +235,26 @@ typedef struct H5G_bt_it_idx_common_t {
} H5G_bt_it_idx_common_t; } H5G_bt_it_idx_common_t;
/* Data passed through B-tree iteration for looking up a name by index */ /* Data passed through B-tree iteration for looking up a name by index */
typedef struct H5G_bt_it_idx1_t { typedef struct H5G_bt_it_gnbi_t {
/* downward */ /* downward */
H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */
haddr_t heap_addr; /*symbol table heap address */ haddr_t heap_addr; /*symbol table heap address */
/* upward */ /* upward */
char *name; /*member name to be returned */ char *name; /*member name to be returned */
} H5G_bt_it_idx1_t; } H5G_bt_it_gnbi_t;
/* Data passed through B-tree iteration for looking up a type by index */ /* Data passed through B-tree iteration for looking up a type by index */
typedef struct H5G_bt_it_idx2_t { typedef struct H5G_bt_it_gtbi_t {
/* downward */ /* downward */
H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */
/* upward */ /* upward */
H5G_obj_t type; /*member type to be returned */ H5G_obj_t type; /*member type to be returned */
} H5G_bt_it_idx2_t; } H5G_bt_it_gtbi_t;
/* Data passed through B-tree iteration for looking up a link by index */ /* Data passed through B-tree iteration for looking up a link by index */
typedef struct H5G_bt_it_idx3_t { typedef struct H5G_bt_it_lbi_t {
/* downward */ /* downward */
H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */
haddr_t heap_addr; /*symbol table heap address */ haddr_t heap_addr; /*symbol table heap address */
@ -264,7 +262,17 @@ typedef struct H5G_bt_it_idx3_t {
/* upward */ /* upward */
H5O_link_t *lnk; /*link to be returned */ H5O_link_t *lnk; /*link to be returned */
hbool_t found; /*whether we found the link */ hbool_t found; /*whether we found the link */
} H5G_bt_it_idx3_t; } H5G_bt_it_lbi_t;
/* Data passed through B-tree iteration for building a table of the links */
typedef struct H5G_bt_it_bt_t {
/* downward */
size_t alloc_nlinks; /* Number of links allocated in table */
haddr_t heap_addr; /* Symbol table heap address */
/* upward */
H5G_link_table_t *ltable; /* Link table to add information to */
} H5G_bt_it_bt_t;
/* Typedefs for "new format" groups */ /* Typedefs for "new format" groups */
/* (fractal heap & v2 B-tree info) */ /* (fractal heap & v2 B-tree info) */
@ -324,12 +332,6 @@ typedef herr_t (*H5G_traverse_t)(H5G_loc_t *grp_loc/*in*/, const char *name,
const H5O_link_t *lnk/*in*/, H5G_loc_t *obj_loc/*out*/, void *operator_data/*in,out*/, const H5O_link_t *lnk/*in*/, H5G_loc_t *obj_loc/*out*/, void *operator_data/*in,out*/,
H5G_own_loc_t *own_loc/*out*/); H5G_own_loc_t *own_loc/*out*/);
/* Data structure to hold table of links for a group */
typedef struct {
size_t nlinks; /* # of links in table */
H5O_link_t *lnks; /* Pointer to array of links */
} H5G_link_table_t;
/*****************************/ /*****************************/
/* Package Private Variables */ /* Package Private Variables */
/*****************************/ /*****************************/
@ -418,20 +420,28 @@ H5_DLL int H5G_node_by_idx(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t
const void *_rt_key, void *_udata); const void *_rt_key, void *_udata);
H5_DLL int H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, 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); const void *_rt_key, void *_udata);
H5_DLL int H5G_node_build_table(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr,
const void *_rt_key, void *_udata);
/* Functions that understand links in groups */ /* Functions that understand links in groups */
struct H5HL_t;
H5_DLL int H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2); 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_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_inc(const void *lnk1, const void *lnk2);
H5_DLL int H5G_link_cmp_corder_dec(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_ent_to_link(H5F_t *f, hid_t dxpl_id, H5O_link_t *lnk, H5_DLL herr_t H5G_ent_to_link(H5F_t *f, hid_t dxpl_id, H5O_link_t *lnk,
haddr_t lheap_addr, const H5G_entry_t *ent, const char *name); haddr_t lheap_addr, struct H5HL_t *heap, const H5G_entry_t *ent, const char *name);
H5_DLL herr_t H5G_ent_to_info(H5F_t *f, hid_t dxpl_id, H5L_info_t *info, H5_DLL herr_t H5G_ent_to_info(H5F_t *f, hid_t dxpl_id, H5L_info_t *info,
haddr_t lheap_addr, const H5G_entry_t *ent); haddr_t lheap_addr, const H5G_entry_t *ent);
H5_DLL herr_t H5G_link_to_info(const H5O_link_t *lnk, H5L_info_t *linfo); H5_DLL herr_t H5G_link_to_info(const H5O_link_t *lnk, H5L_info_t *linfo);
H5_DLL herr_t H5G_link_copy_file(H5F_t *dst_file, hid_t dxpl_id, 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, const H5O_link_t *_src_lnk, const H5O_loc_t *src_oloc, H5O_link_t *dst_lnk,
H5O_copy_t *cpy_info); H5O_copy_t *cpy_info);
H5_DLL herr_t H5G_link_sort_table(H5G_link_table_t *ltable, H5L_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,
void *op_data);
H5_DLL herr_t H5G_link_release_table(H5G_link_table_t *ltable); 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, H5_DLL herr_t H5G_link_name_replace(H5F_t *file, hid_t dxpl_id,
H5RS_str_t *grp_full_path_r, const char *lnk_name, H5L_type_t lnk_type, H5RS_str_t *grp_full_path_r, const char *lnk_name, H5L_type_t lnk_type,
@ -451,7 +461,7 @@ 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, H5L_index_t idx_type,
H5_iter_order_t order, hsize_t n); 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, 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_obj, 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); 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, H5_DLL herr_t H5G_compact_lookup(H5O_loc_t *grp_oloc, const char *name,
H5O_link_t *lnk, hid_t dxpl_id); H5O_link_t *lnk, hid_t dxpl_id);

View File

@ -104,14 +104,12 @@ H5_DLL hid_t H5Gcreate(hid_t loc_id, const char *name, size_t size_hint);
H5_DLL hid_t H5Gcreate_expand(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id); H5_DLL hid_t H5Gcreate_expand(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id);
H5_DLL hid_t H5Gopen(hid_t loc_id, const char *name); H5_DLL hid_t H5Gopen(hid_t loc_id, const char *name);
H5_DLL hid_t H5Gopen_expand(hid_t loc_id, const char *name, hid_t gapl_id); H5_DLL hid_t H5Gopen_expand(hid_t loc_id, const char *name, hid_t gapl_id);
H5_DLL herr_t H5Gclose(hid_t group_id);
H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx,
H5G_iterate_t op, void *op_data);
H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs); H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs);
H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx); H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx);
H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name,
hbool_t follow_link, H5G_stat_t *statbuf/*out*/); hbool_t follow_link, H5G_stat_t *statbuf/*out*/);
H5_DLL hid_t H5Gget_create_plist(hid_t group_id); H5_DLL hid_t H5Gget_create_plist(hid_t group_id);
H5_DLL herr_t H5Gclose(hid_t group_id);
/* Functions and variables defined for compatibility with previous versions /* Functions and variables defined for compatibility with previous versions
* of the HDF5 API. * of the HDF5 API.
@ -134,6 +132,8 @@ H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char* name,
H5_DLL herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment); H5_DLL herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment);
H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize,
char *buf); char *buf);
H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx,
H5G_iterate_t op, void *op_data);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -213,7 +213,7 @@ herr_t
H5G_stab_insert_real(H5F_t *f, H5O_stab_t *stab, const char *name, H5G_stab_insert_real(H5F_t *f, H5O_stab_t *stab, const char *name,
H5O_link_t *obj_lnk, hid_t dxpl_id) H5O_link_t *obj_lnk, hid_t dxpl_id)
{ {
H5G_bt_ud1_t udata; /* Data to pass through B-tree */ H5G_bt_ins_t udata; /* Data to pass through B-tree */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_insert_real, FAIL) FUNC_ENTER_NOAPI(H5G_stab_insert_real, FAIL)
@ -272,7 +272,7 @@ H5G_stab_insert(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk,
HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table") HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table")
if(H5G_stab_insert_real(grp_oloc->file, &stab, name, obj_lnk, dxpl_id) < 0) if(H5G_stab_insert_real(grp_oloc->file, &stab, name, obj_lnk, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5B_ITER_ERROR, "unable to insert the name") HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "unable to insert the name")
done: done:
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
@ -296,7 +296,7 @@ H5G_stab_remove(H5O_loc_t *loc, hid_t dxpl_id, H5RS_str_t *grp_full_path_r,
const char *name) const char *name)
{ {
H5O_stab_t stab; /*symbol table message */ H5O_stab_t stab; /*symbol table message */
H5G_bt_ud2_t udata; /*data to pass through B-tree */ H5G_bt_rm_t udata; /*data to pass through B-tree */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_remove, FAIL) FUNC_ENTER_NOAPI(H5G_stab_remove, FAIL)
@ -340,7 +340,7 @@ H5G_stab_remove_by_idx(H5O_loc_t *grp_oloc, hid_t dxpl_id, H5RS_str_t *grp_full_
H5_iter_order_t order, hsize_t n) H5_iter_order_t order, hsize_t n)
{ {
H5O_stab_t stab; /* Symbol table message */ H5O_stab_t stab; /* Symbol table message */
H5G_bt_ud2_t udata; /* Data to pass through B-tree */ H5G_bt_rm_t udata; /* Data to pass through B-tree */
H5O_link_t obj_lnk; /* Object's link within group */ H5O_link_t obj_lnk; /* Object's link within group */
hbool_t lnk_copied = FALSE; /* Whether the link was copied */ hbool_t lnk_copied = FALSE; /* Whether the link was copied */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
@ -394,7 +394,7 @@ done:
herr_t herr_t
H5G_stab_delete(H5F_t *f, hid_t dxpl_id, const H5O_stab_t *stab, hbool_t adj_link) H5G_stab_delete(H5F_t *f, hid_t dxpl_id, const H5O_stab_t *stab, hbool_t adj_link)
{ {
H5G_bt_ud2_t udata; /*data to pass through B-tree */ H5G_bt_rm_t udata; /*data to pass through B-tree */
herr_t ret_value = SUCCEED; herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(H5G_stab_delete, FAIL); FUNC_ENTER_NOAPI(H5G_stab_delete, FAIL);
@ -439,8 +439,8 @@ H5G_stab_iterate(H5O_loc_t *oloc, hid_t dxpl_id, H5_iter_order_t order,
hsize_t skip, hsize_t *last_lnk, hid_t gid, hsize_t skip, hsize_t *last_lnk, hid_t gid,
H5G_link_iterate_t *lnk_op, void *op_data) H5G_link_iterate_t *lnk_op, void *op_data)
{ {
H5G_bt_it_ud1_t udata; /* User data to pass to B-tree callback */
H5O_stab_t stab; /* Info about symbol table */ H5O_stab_t stab; /* Info about symbol table */
H5G_link_table_t ltable = {0, NULL}; /* Link table */
herr_t ret_value; herr_t ret_value;
FUNC_ENTER_NOAPI(H5G_stab_iterate, FAIL) FUNC_ENTER_NOAPI(H5G_stab_iterate, FAIL)
@ -456,6 +456,8 @@ H5G_stab_iterate(H5O_loc_t *oloc, hid_t dxpl_id, H5_iter_order_t order,
/* Check on iteration order */ /* Check on iteration order */
/* ("native" iteration order is increasing for this link storage mechanism) */ /* ("native" iteration order is increasing for this link storage mechanism) */
if(order != H5_ITER_DEC) { if(order != H5_ITER_DEC) {
H5G_bt_it_it_t udata; /* User data to pass to B-tree callback */
/* Build udata to pass through H5B_iterate() to H5G_node_iterate() */ /* Build udata to pass through H5B_iterate() to H5G_node_iterate() */
udata.group_id = gid; udata.group_id = gid;
udata.heap_addr = stab.heap_addr; udata.heap_addr = stab.heap_addr;
@ -465,16 +467,37 @@ H5G_stab_iterate(H5O_loc_t *oloc, hid_t dxpl_id, H5_iter_order_t order,
udata.op_data = op_data; udata.op_data = op_data;
/* Iterate over the group members */ /* Iterate over the group members */
if((ret_value = H5B_iterate(oloc->file, H5AC_dxpl_id, H5B_SNODE, if((ret_value = H5B_iterate(oloc->file, dxpl_id, H5B_SNODE,
H5G_node_iterate, stab.btree_addr, &udata)) < 0) H5G_node_iterate, stab.btree_addr, &udata)) < 0)
HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed");
} /* end if */ } /* end if */
else { else {
HDfprintf(stderr, "%s: Decreasing iteration order for symbol table storage not supported yet!\n", FUNC); H5G_bt_it_bt_t udata; /* User data to pass to B-tree callback */
HGOTO_ERROR(H5E_SYM, H5E_UNSUPPORTED, FAIL, "decreasing iteration order for symbol table storage not supported yet")
/* Build udata to pass through H5B_iterate() to H5G_node_iterate() */
udata.alloc_nlinks = 0;
udata.heap_addr = stab.heap_addr;
udata.ltable = &ltable;
/* Iterate over the group members */
if(H5B_iterate(oloc->file, dxpl_id, H5B_SNODE, H5G_node_build_table,
stab.btree_addr, &udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to build link table")
/* Sort link table in correct iteration order */
if(H5G_link_sort_table(&ltable, H5L_INDEX_NAME, order) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting link messages")
/* Iterate over links in table */
if((ret_value = H5G_link_iterate_table(&ltable, skip, last_lnk, gid, lnk_op, op_data)) < 0)
HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed");
} /* end else */ } /* end else */
done: done:
/* Release resources */
if(ltable.lnks && H5G_link_release_table(&ltable) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table")
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_stab_iterate() */ } /* end H5G_stab_iterate() */
@ -536,7 +559,7 @@ done:
static herr_t static herr_t
H5G_stab_get_name_by_idx_cb(const H5G_entry_t *ent, void *_udata) H5G_stab_get_name_by_idx_cb(const H5G_entry_t *ent, void *_udata)
{ {
H5G_bt_it_idx1_t *udata = (H5G_bt_it_idx1_t *)_udata; H5G_bt_it_gnbi_t *udata = (H5G_bt_it_gnbi_t *)_udata;
H5HL_t *heap = NULL; /* Pointer to local heap for group */ H5HL_t *heap = NULL; /* Pointer to local heap for group */
size_t name_off; /* Offset of name in heap */ size_t name_off; /* Offset of name in heap */
const char *name; /* Pointer to name string in heap */ const char *name; /* Pointer to name string in heap */
@ -586,7 +609,7 @@ H5G_stab_get_name_by_idx(H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n,
char* name, size_t size, hid_t dxpl_id) char* name, size_t size, hid_t dxpl_id)
{ {
H5O_stab_t stab; /* Info about local heap & B-tree */ H5O_stab_t stab; /* Info about local heap & B-tree */
H5G_bt_it_idx1_t udata; /* Iteration information */ H5G_bt_it_gnbi_t udata; /* Iteration information */
ssize_t ret_value; /* Return value */ ssize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_get_name_by_idx, FAIL) FUNC_ENTER_NOAPI(H5G_stab_get_name_by_idx, FAIL)
@ -663,7 +686,7 @@ done:
static herr_t static herr_t
H5G_stab_get_type_by_idx_cb(const H5G_entry_t *ent, void *_udata) H5G_stab_get_type_by_idx_cb(const H5G_entry_t *ent, void *_udata)
{ {
H5G_bt_it_idx2_t *udata = (H5G_bt_it_idx2_t *)_udata; H5G_bt_it_gtbi_t *udata = (H5G_bt_it_gtbi_t *)_udata;
H5O_loc_t tmp_oloc; /* Temporary object location */ H5O_loc_t tmp_oloc; /* Temporary object location */
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_stab_get_type_by_idx_cb) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_stab_get_type_by_idx_cb)
@ -711,7 +734,7 @@ H5G_obj_t
H5G_stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id) H5G_stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id)
{ {
H5O_stab_t stab; /* Info about local heap & B-tree */ H5O_stab_t stab; /* Info about local heap & B-tree */
H5G_bt_it_idx2_t udata; /* User data for B-tree callback */ H5G_bt_it_gtbi_t udata; /* User data for B-tree callback */
H5G_obj_t ret_value; /* Return value */ H5G_obj_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_get_type_by_idx, H5G_UNKNOWN) FUNC_ENTER_NOAPI(H5G_stab_get_type_by_idx, H5G_UNKNOWN)
@ -773,7 +796,7 @@ H5G_stab_lookup_cb(const H5G_entry_t *ent, void *_udata)
if(udata->lnk) { if(udata->lnk) {
/* Convert the entry to a link */ /* Convert the entry to a link */
if(H5G_ent_to_link(udata->file, udata->dxpl_id, udata->lnk, udata->heap_addr, if(H5G_ent_to_link(udata->file, udata->dxpl_id, udata->lnk, udata->heap_addr,
ent, udata->name) < 0) NULL, ent, udata->name) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, FAIL, "unable to convert symbol table entry to link") HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, FAIL, "unable to convert symbol table entry to link")
} /* end if */ } /* end if */
@ -799,7 +822,7 @@ herr_t
H5G_stab_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, H5G_stab_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk,
hid_t dxpl_id) hid_t dxpl_id)
{ {
H5G_bt_ud3_t bt_udata; /* Data to pass through B-tree */ H5G_bt_lkp_t bt_udata; /* Data to pass through B-tree */
H5G_stab_fnd_ud2_t udata; /* 'User data' to give to callback */ H5G_stab_fnd_ud2_t udata; /* 'User data' to give to callback */
H5O_stab_t stab; /* Symbol table message */ H5O_stab_t stab; /* Symbol table message */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
@ -854,13 +877,9 @@ done:
static herr_t static herr_t
H5G_stab_lookup_by_idx_cb(const H5G_entry_t *ent, void *_udata) H5G_stab_lookup_by_idx_cb(const H5G_entry_t *ent, void *_udata)
{ {
H5G_bt_it_idx3_t *udata = (H5G_bt_it_idx3_t *)_udata; H5G_bt_it_lbi_t *udata = (H5G_bt_it_lbi_t *)_udata;
H5HL_t *heap; /* Pointer to local heap for group */ H5HL_t *heap = NULL; /* Pointer to local heap for group */
size_t name_off; /* Offset of name in heap */
const char *name; /* Pointer to name string in heap */ const char *name; /* Pointer to name string in heap */
size_t name_len; /* Length of link name */
char buf[1024]; /* Buffer for name */
char *s = NULL; /* Pointer to copy of name string */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_stab_lookup_by_idx_cb) FUNC_ENTER_NOAPI_NOINIT(H5G_stab_lookup_by_idx_cb)
@ -869,43 +888,23 @@ H5G_stab_lookup_by_idx_cb(const H5G_entry_t *ent, void *_udata)
HDassert(ent); HDassert(ent);
HDassert(udata); HDassert(udata);
/* Get name offset in heap */
name_off = ent->name_off;
/* Pin the heap down in memory */ /* Pin the heap down in memory */
if(NULL == (heap = H5HL_protect(udata->common.f, udata->common.dxpl_id, udata->heap_addr))) if(NULL == (heap = H5HL_protect(udata->common.f, udata->common.dxpl_id, udata->heap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name") HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name")
/* Duplicate the link name */ /* Duplicate the link name */
name = H5HL_offset_into(udata->common.f, heap, name_off); name = H5HL_offset_into(udata->common.f, heap, ent->name_off);
HDassert(name); HDassert(name);
name_len = HDstrlen(name);
/* Allocate space or point to existing buffer */
if((name_len + 1) > sizeof(buf)) {
if(NULL == (s = H5MM_malloc(name_len + 1)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
} /* end if */
else
s = buf;
/* Make a copy of the name */
HDstrcpy(s, name);
/* Unlock the heap */
if(H5HL_unprotect(udata->common.f, udata->common.dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name")
heap = NULL; name = NULL;
/* Convert the entry to a link */ /* Convert the entry to a link */
if(H5G_ent_to_link(udata->common.f, udata->common.dxpl_id, udata->lnk, udata->heap_addr, ent, s) < 0) if(H5G_ent_to_link(udata->common.f, udata->common.dxpl_id, udata->lnk, HADDR_UNDEF, heap, ent, name) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, FAIL, "unable to convert symbol table entry to link") HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, FAIL, "unable to convert symbol table entry to link")
udata->found = TRUE; udata->found = TRUE;
done: done:
/* Free the memory for the name, if we used a dynamically allocated buffer */ /* Unlock the heap */
if(s && s != buf) if(heap && H5HL_unprotect(udata->common.f, udata->common.dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0)
H5MM_xfree(s); HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name")
FUNC_LEAVE_NOAPI(ret_value) FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_stab_lookup_by_idx_cb */ } /* end H5G_stab_lookup_by_idx_cb */
@ -928,7 +927,7 @@ herr_t
H5G_stab_lookup_by_idx(H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_t n, H5G_stab_lookup_by_idx(H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_t n,
H5O_link_t *lnk, hid_t dxpl_id) H5O_link_t *lnk, hid_t dxpl_id)
{ {
H5G_bt_it_idx3_t udata; /* Iteration information */ H5G_bt_it_lbi_t udata; /* Iteration information */
H5O_stab_t stab; /* Symbol table message */ H5O_stab_t stab; /* Symbol table message */
herr_t ret_value = SUCCEED; /* Return value */ herr_t ret_value = SUCCEED; /* Return value */

View File

@ -2430,7 +2430,7 @@ H5O_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
{ {
H5O_iter_ud1_t *udata = (H5O_iter_ud1_t *)_udata; /* Operator user data */ H5O_iter_ud1_t *udata = (H5O_iter_ud1_t *)_udata; /* Operator user data */
htri_t try_remove = FALSE; /* Whether to try removing a message */ htri_t try_remove = FALSE; /* Whether to try removing a message */
herr_t ret_value = H5O_ITER_CONT; /* Return value */ herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_remove_cb) FUNC_ENTER_NOAPI_NOINIT(H5O_remove_cb)
@ -2441,12 +2441,12 @@ H5O_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
if(udata->op) { if(udata->op) {
/* Call the iterator callback */ /* Call the iterator callback */
if((try_remove = (udata->op)(mesg->native, sequence, udata->op_data)) < 0) if((try_remove = (udata->op)(mesg->native, sequence, udata->op_data)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5O_ITER_ERROR, "object header message deletion callback failed") HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "object header message deletion callback failed")
} /* end if */ } /* end if */
else { else {
/* If there's no callback routine, does the sequence # match? */ /* If there's no callback routine, does the sequence # match? */
if((int)sequence == udata->sequence || H5O_ALL == udata->sequence) if((int)sequence == udata->sequence || H5O_ALL == udata->sequence)
try_remove = H5O_ITER_STOP; try_remove = H5_ITER_STOP;
} /* end else */ } /* end else */
/* Try removing the message, if indicated */ /* Try removing the message, if indicated */
@ -2460,7 +2460,7 @@ H5O_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
else { else {
/* Convert message into a null message */ /* Convert message into a null message */
if(H5O_release_mesg(udata->f, udata->dxpl_id, oh, mesg, TRUE, udata->adj_link) < 0) if(H5O_release_mesg(udata->f, udata->dxpl_id, oh, mesg, TRUE, udata->adj_link) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5O_ITER_ERROR, "unable to convert into null message") HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to convert into null message")
/* Indicate that the object header was modified */ /* Indicate that the object header was modified */
*oh_flags_ptr |= H5AC__DIRTIED_FLAG; *oh_flags_ptr |= H5AC__DIRTIED_FLAG;
@ -2468,7 +2468,7 @@ H5O_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
/* Break out now, if we've found the correct message */ /* Break out now, if we've found the correct message */
if(udata->sequence == H5O_FIRST || udata->sequence != H5O_ALL) if(udata->sequence == H5O_FIRST || udata->sequence != H5O_ALL)
HGOTO_DONE(H5O_ITER_STOP) HGOTO_DONE(H5_ITER_STOP)
} /* end if */ } /* end if */
done: done:
@ -3209,7 +3209,7 @@ H5O_iterate_real(const H5O_loc_t *loc, const H5O_msg_class_t *type, H5AC_protect
unsigned idx; /* Absolute index of current message in all messages */ unsigned idx; /* Absolute index of current message in all messages */
unsigned sequence; /* Relative index of current message for messages of type */ unsigned sequence; /* Relative index of current message for messages of type */
H5O_mesg_t *idx_msg; /* Pointer to current message */ H5O_mesg_t *idx_msg; /* Pointer to current message */
herr_t ret_value = H5O_ITER_CONT; /* Return value */ herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_iterate_real) FUNC_ENTER_NOAPI_NOINIT(H5O_iterate_real)

View File

@ -449,7 +449,7 @@ H5O_linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata)
H5O_linfo_postcopy_ud_t *udata = (H5O_linfo_postcopy_ud_t *)_udata; /* 'User data' passed in */ H5O_linfo_postcopy_ud_t *udata = (H5O_linfo_postcopy_ud_t *)_udata; /* 'User data' passed in */
H5O_link_t dst_lnk; /* Destination link to insert */ H5O_link_t dst_lnk; /* Destination link to insert */
hbool_t dst_lnk_init = FALSE; /* Whether the destination link is initialized */ hbool_t dst_lnk_init = FALSE; /* Whether the destination link is initialized */
herr_t ret_value = H5B2_ITER_CONT; /* Return value */ herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_linfo_post_copy_file_cb) FUNC_ENTER_NOAPI_NOINIT(H5O_linfo_post_copy_file_cb)
@ -460,13 +460,13 @@ H5O_linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata)
/* Copy the link (and the object it points to) */ /* Copy the link (and the object it points to) */
if(H5G_link_copy_file(udata->dst_oloc->file, udata->dxpl_id, src_lnk, if(H5G_link_copy_file(udata->dst_oloc->file, udata->dxpl_id, src_lnk,
udata->src_oloc, &dst_lnk, udata->cpy_info) < 0) udata->src_oloc, &dst_lnk, udata->cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5B2_ITER_ERROR, "unable to copy link") HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy link")
dst_lnk_init = TRUE; dst_lnk_init = TRUE;
/* Insert the new object in the destination file's group */ /* Insert the new object in the destination file's group */
/* (Doesn't increment the link count - that's already been taken care of for hard links) */ /* (Doesn't increment the link count - that's already been taken care of for hard links) */
if(H5G_dense_insert(udata->dst_oloc->file, udata->dxpl_id, udata->dst_linfo, &dst_lnk) < 0) if(H5G_dense_insert(udata->dst_oloc->file, udata->dxpl_id, udata->dst_linfo, &dst_lnk) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5B2_ITER_ERROR, "unable to insert destination link") HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert destination link")
done: done:
/* Check if the destination link has been initialized */ /* Check if the destination link has been initialized */

View File

@ -353,14 +353,6 @@ typedef struct H5O_stab_t {
haddr_t heap_addr; /*address of name heap */ haddr_t heap_addr; /*address of name heap */
} H5O_stab_t; } H5O_stab_t;
/* Define return values from operator callback function for H5O_iterate */
/* (Actually, any postive value will cause the iterator to stop and pass back
* that positive value to the function that called the iterator)
*/
#define H5O_ITER_ERROR (-1)
#define H5O_ITER_CONT (0)
#define H5O_ITER_STOP (1)
/* Typedef for iteration operations */ /* Typedef for iteration operations */
typedef herr_t (*H5O_operator_t)(const void *mesg/*in*/, unsigned idx, typedef herr_t (*H5O_operator_t)(const void *mesg/*in*/, unsigned idx,
void *operator_data/*in,out*/); void *operator_data/*in,out*/);

View File

@ -1207,7 +1207,7 @@ H5T_init_interface(void)
/* From long long to floats */ /* From long long to floats */
status |= H5T_register(H5T_PERS_HARD, "llong_flt", native_llong, native_float, H5T_conv_llong_float, H5AC_dxpl_id, FALSE); status |= H5T_register(H5T_PERS_HARD, "llong_flt", native_llong, native_float, H5T_conv_llong_float, H5AC_dxpl_id, FALSE);
status |= H5T_register(H5T_PERS_HARD, "llong_dbl", native_llong, native_double, H5T_conv_llong_double, H5AC_dxpl_id, FALSE); status |= H5T_register(H5T_PERS_HARD, "llong_dbl", native_llong, native_double, H5T_conv_llong_double, H5AC_dxpl_id, FALSE);
#if H5T_CONV_INTERNAL_LLONG_LDOUBLE #ifdef H5T_CONV_INTERNAL_LLONG_LDOUBLE
status |= H5T_register(H5T_PERS_HARD, "llong_ldbl", native_llong, native_ldouble, H5T_conv_llong_ldouble, H5AC_dxpl_id, FALSE); status |= H5T_register(H5T_PERS_HARD, "llong_ldbl", native_llong, native_ldouble, H5T_conv_llong_ldouble, H5AC_dxpl_id, FALSE);
#endif /* H5T_CONV_INTERNAL_LLONG_LDOUBLE */ #endif /* H5T_CONV_INTERNAL_LLONG_LDOUBLE */
@ -1216,7 +1216,7 @@ H5T_init_interface(void)
status |= H5T_register(H5T_PERS_HARD, "ullong_flt", native_ullong, native_float, H5T_conv_ullong_float, H5AC_dxpl_id, FALSE); status |= H5T_register(H5T_PERS_HARD, "ullong_flt", native_ullong, native_float, H5T_conv_ullong_float, H5AC_dxpl_id, FALSE);
status |= H5T_register(H5T_PERS_HARD, "ullong_dbl", native_ullong, native_double, H5T_conv_ullong_double, H5AC_dxpl_id, FALSE); status |= H5T_register(H5T_PERS_HARD, "ullong_dbl", native_ullong, native_double, H5T_conv_ullong_double, H5AC_dxpl_id, FALSE);
#endif /* H5T_CONV_INTERNAL_ULLONG_FP */ #endif /* H5T_CONV_INTERNAL_ULLONG_FP */
#if H5T_CONV_INTERNAL_ULLONG_LDOUBLE #ifdef H5T_CONV_INTERNAL_ULLONG_LDOUBLE
status |= H5T_register(H5T_PERS_HARD, "ullong_ldbl", native_ullong, native_ldouble, H5T_conv_ullong_ldouble, H5AC_dxpl_id, FALSE); status |= H5T_register(H5T_PERS_HARD, "ullong_ldbl", native_ullong, native_ldouble, H5T_conv_ullong_ldouble, H5AC_dxpl_id, FALSE);
#endif /* H5T_CONV_INTERNAL_ULLONG_LDOUBLE */ #endif /* H5T_CONV_INTERNAL_ULLONG_LDOUBLE */
@ -1280,7 +1280,7 @@ H5T_init_interface(void)
status |= H5T_register(H5T_PERS_HARD, "flt_llong", native_float, native_llong, H5T_conv_float_llong, H5AC_dxpl_id, FALSE); status |= H5T_register(H5T_PERS_HARD, "flt_llong", native_float, native_llong, H5T_conv_float_llong, H5AC_dxpl_id, FALSE);
status |= H5T_register(H5T_PERS_HARD, "dbl_llong", native_double, native_llong, H5T_conv_double_llong, H5AC_dxpl_id, FALSE); status |= H5T_register(H5T_PERS_HARD, "dbl_llong", native_double, native_llong, H5T_conv_double_llong, H5AC_dxpl_id, FALSE);
#endif /* H5T_CONV_INTERNAL_FP_LLONG */ #endif /* H5T_CONV_INTERNAL_FP_LLONG */
#if H5T_CONV_INTERNAL_LDOUBLE_LLONG #ifdef H5T_CONV_INTERNAL_LDOUBLE_LLONG
status |= H5T_register(H5T_PERS_HARD, "ldbl_llong", native_ldouble, native_llong, H5T_conv_ldouble_llong, H5AC_dxpl_id, FALSE); status |= H5T_register(H5T_PERS_HARD, "ldbl_llong", native_ldouble, native_llong, H5T_conv_ldouble_llong, H5AC_dxpl_id, FALSE);
#endif /* H5T_CONV_INTERNAL_LDOUBLE_LLONG */ #endif /* H5T_CONV_INTERNAL_LDOUBLE_LLONG */

View File

@ -102,7 +102,7 @@
/* Define an internal macro for converting long long to long double. Mac OS 10.4 gives some /* Define an internal macro for converting long long to long double. Mac OS 10.4 gives some
* incorrect conversions. */ * incorrect conversions. */
#if (H5_WANT_DATA_ACCURACY && H5_INTEGER_TO_LDOUBLE_ACCURATE && H5_LLONG_TO_LDOUBLE_CORRECT) || \ #if (H5_WANT_DATA_ACCURACY && H5_INTEGER_TO_LDOUBLE_ACCURATE && defined(H5_LLONG_TO_LDOUBLE_CORRECT)) || \
(!H5_WANT_DATA_ACCURACY) (!H5_WANT_DATA_ACCURACY)
#define H5T_CONV_INTERNAL_LLONG_LDOUBLE 1 #define H5T_CONV_INTERNAL_LLONG_LDOUBLE 1
#endif #endif
@ -121,7 +121,7 @@
* compiler tries to do the conversion. For Cygwin, compiler doesn't do rounding correctly. * compiler tries to do the conversion. For Cygwin, compiler doesn't do rounding correctly.
* Mac OS 10.4 gives some incorrect result. */ * Mac OS 10.4 gives some incorrect result. */
#if (H5_WANT_DATA_ACCURACY && H5_ULLONG_TO_FP_CAST_WORKS && H5_ULONG_TO_FP_BOTTOM_BIT_ACCURATE && \ #if (H5_WANT_DATA_ACCURACY && H5_ULLONG_TO_FP_CAST_WORKS && H5_ULONG_TO_FP_BOTTOM_BIT_ACCURATE && \
H5_ULLONG_TO_LDOUBLE_PRECISION && H5_LLONG_TO_LDOUBLE_CORRECT) || (!H5_WANT_DATA_ACCURACY && \ H5_ULLONG_TO_LDOUBLE_PRECISION && defined(H5_LLONG_TO_LDOUBLE_CORRECT)) || (!H5_WANT_DATA_ACCURACY && \
H5_ULLONG_TO_FP_CAST_WORKS) H5_ULLONG_TO_FP_CAST_WORKS)
#define H5T_CONV_INTERNAL_ULLONG_LDOUBLE 1 #define H5T_CONV_INTERNAL_ULLONG_LDOUBLE 1
#endif #endif
@ -151,7 +151,7 @@
* conversions. Mac OS 10.4 gives incorrect conversions. HP-UX 11.00 compiler generates floating exception. * conversions. Mac OS 10.4 gives incorrect conversions. HP-UX 11.00 compiler generates floating exception.
* The hard conversion on Windows .NET 2003 has a bug and gives wrong exception value. */ * The hard conversion on Windows .NET 2003 has a bug and gives wrong exception value. */
#if (H5_WANT_DATA_ACCURACY && !defined(H5_HW_FP_TO_LLONG_NOT_WORKS) && H5_LDOUBLE_TO_INTEGER_ACCURATE && \ #if (H5_WANT_DATA_ACCURACY && !defined(H5_HW_FP_TO_LLONG_NOT_WORKS) && H5_LDOUBLE_TO_INTEGER_ACCURATE && \
H5_LDOUBLE_TO_INTEGER_WORKS && H5_LDOUBLE_TO_LLONG_ACCURATE) || \ H5_LDOUBLE_TO_INTEGER_WORKS && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)) || \
(!H5_WANT_DATA_ACCURACY && !defined(H5_HW_FP_TO_LLONG_NOT_WORKS) && H5_LDOUBLE_TO_INTEGER_WORKS) (!H5_WANT_DATA_ACCURACY && !defined(H5_HW_FP_TO_LLONG_NOT_WORKS) && H5_LDOUBLE_TO_INTEGER_WORKS)
#define H5T_CONV_INTERNAL_LDOUBLE_LLONG 1 #define H5T_CONV_INTERNAL_LDOUBLE_LLONG 1
#endif #endif
@ -170,7 +170,7 @@
* incorrect conversions. Mac OS 10.4 gives incorrect conversions. HP-UX 11.00 compiler generates * incorrect conversions. Mac OS 10.4 gives incorrect conversions. HP-UX 11.00 compiler generates
* floating exception. */ * floating exception. */
#if (H5_WANT_DATA_ACCURACY && H5_LDOUBLE_TO_INTEGER_ACCURATE && H5_LDOUBLE_TO_INTEGER_WORKS && \ #if (H5_WANT_DATA_ACCURACY && H5_LDOUBLE_TO_INTEGER_ACCURATE && H5_LDOUBLE_TO_INTEGER_WORKS && \
H5_FP_TO_ULLONG_ACCURATE && defined(H5_FP_TO_ULLONG_RIGHT_MAXIMUM) && H5_LDOUBLE_TO_LLONG_ACCURATE) || \ H5_FP_TO_ULLONG_ACCURATE && defined(H5_FP_TO_ULLONG_RIGHT_MAXIMUM) && defined(H5_LDOUBLE_TO_LLONG_ACCURATE)) || \
(!H5_WANT_DATA_ACCURACY && H5_LDOUBLE_TO_INTEGER_WORKS) (!H5_WANT_DATA_ACCURACY && H5_LDOUBLE_TO_INTEGER_WORKS)
#define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 1 #define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 1
#else #else

View File

@ -219,7 +219,7 @@ MINOR, LINK, H5E_TRAVERSE, Link traversal failure
MINOR, LINK, H5E_NLINKS, Too many soft links in path MINOR, LINK, H5E_NLINKS, Too many soft links in path
MINOR, LINK, H5E_NOTREGISTERED, Link class not registered MINOR, LINK, H5E_NOTREGISTERED, Link class not registered
MINOR, LINK, H5E_CANTMOVE, Move callback returned error MINOR, LINK, H5E_CANTMOVE, Move callback returned error
MINOR, LINK, H5E_CANTSORT, Can't sort objects
# Parallel MPI errors # Parallel MPI errors
MINOR, MPI, H5E_MPI, Some MPI function failed MINOR, MPI, H5E_MPI, Some MPI function failed

View File

@ -236,6 +236,14 @@ typedef enum {
H5_ITER_N /* Number of iteration orders */ H5_ITER_N /* Number of iteration orders */
} H5_iter_order_t; } H5_iter_order_t;
/* Iteration callback values */
/* (Actually, any postive value will cause the iterator to stop and pass back
* that positive value to the function that called the iterator)
*/
#define H5_ITER_ERROR (-1)
#define H5_ITER_CONT (0)
#define H5_ITER_STOP (1)
/* Functions in H5.c */ /* Functions in H5.c */
H5_DLL herr_t H5open(void); H5_DLL herr_t H5open(void);
H5_DLL herr_t H5close(void); H5_DLL herr_t H5close(void);

View File

@ -63,10 +63,10 @@ iter_cb(const void *_record, void *_op_data)
hsize_t *idx = (hsize_t *)_op_data; hsize_t *idx = (hsize_t *)_op_data;
if(*record != *idx) if(*record != *idx)
return(H5B2_ITER_ERROR); return(H5_ITER_ERROR);
(*idx)++; (*idx)++;
return(H5B2_ITER_CONT); return(H5_ITER_CONT);
} /* end iter_cb() */ } /* end iter_cb() */

View File

@ -5193,7 +5193,6 @@ corder_create_empty(hid_t fapl)
TESTING("creating empty group with creation order indexing") TESTING("creating empty group with creation order indexing")
/* Create file */ /* Create file */
/* (with creation order tracking for the root group) */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename); h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
@ -5312,7 +5311,6 @@ corder_create_compact(hid_t fapl)
TESTING("creating compact group with creation order indexing") TESTING("creating compact group with creation order indexing")
/* Create file */ /* Create file */
/* (with creation order tracking for the root group) */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename); h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
@ -5435,7 +5433,6 @@ corder_create_dense(hid_t fapl)
TESTING("creating dense group with creation order indexing") TESTING("creating dense group with creation order indexing")
/* Create file */ /* Create file */
/* (with creation order tracking for the root group) */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename); h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
@ -5573,7 +5570,6 @@ corder_transition(hid_t fapl)
TESTING("transitioning group with creation order indexing between dense & compact forms") TESTING("transitioning group with creation order indexing between dense & compact forms")
/* Create file */ /* Create file */
/* (with creation order tracking for the root group) */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename); h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
@ -5809,7 +5805,6 @@ corder_delete(hid_t fapl)
* before deleting group */ * before deleting group */
for(reopen_file = FALSE; reopen_file <= TRUE; reopen_file++) { for(reopen_file = FALSE; reopen_file <= TRUE; reopen_file++) {
/* Create file */ /* Create file */
/* (with creation order tracking for the root group) */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename); h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR
@ -5899,7 +5894,6 @@ error:
} H5E_END_TRY; } H5E_END_TRY;
return -1; return -1;
} /* end corder_delete() */ } /* end corder_delete() */
#endif /* QAK */
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
@ -6060,7 +6054,6 @@ error:
return(-1); return(-1);
} /* end link_info_by_idx_check() */ } /* end link_info_by_idx_check() */
#ifndef QAK
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function: link_info_by_idx * Function: link_info_by_idx
@ -6112,7 +6105,6 @@ link_info_by_idx(hid_t fapl)
} /* end else */ } /* end else */
/* Create file */ /* Create file */
/* (with creation order tracking for the root group) */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename); h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
@ -6489,7 +6481,6 @@ delete_by_idx(hid_t fapl)
} /* end else */ } /* end else */
/* Create file */ /* Create file */
/* (with creation order tracking for the root group) */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename); h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
@ -6742,7 +6733,6 @@ error:
} H5E_END_TRY; } H5E_END_TRY;
return -1; return -1;
} /* end delete_by_idx() */ } /* end delete_by_idx() */
#endif /* QAK */
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
@ -6976,6 +6966,350 @@ error:
return -1; return -1;
} /* end delete_by_idx_old() */ } /* end delete_by_idx_old() */
#endif /* QAK */
/*-------------------------------------------------------------------------
* Function: link_iterate_cb
*
* Purpose: Callback routine for iterating over links in group
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Monday, November 20, 2006
*
*-------------------------------------------------------------------------
*/
static int
link_iterate_cb(hid_t group_id, const char *link_name, const H5L_info_t * info,
void *op_data)
{
return(H5_ITER_CONT);
} /* end link_iterate_cb() */
/*-------------------------------------------------------------------------
* Function: link_iterate
*
* Purpose: Create a group with creation order indices and test deleting
* links by index.
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Tuesday, November 14, 2006
*
*-------------------------------------------------------------------------
*/
static int
link_iterate(hid_t fapl)
{
hid_t file_id = (-1); /* File ID */
hid_t group_id = (-1); /* Group ID */
hid_t gcpl_id = (-1); /* Group creation property list ID */
H5L_index_t idx_type; /* Type of index to operate on */
H5_iter_order_t order; /* Order within in the index */
hbool_t use_index; /* Use index on creation order values */
unsigned max_compact; /* Maximum # of links to store in group compactly */
unsigned min_dense; /* Minimum # of links to store in group "densely" */
H5L_info_t linfo; /* Link info struct */
char objname[NAME_BUF_SIZE]; /* Object name */
char filename[NAME_BUF_SIZE];/* File name */
char tmpname[NAME_BUF_SIZE]; /* Temporary link name */
unsigned u; /* Local index variable */
herr_t ret; /* Generic return value */
/* Loop over operating on different indices on link fields */
for(idx_type = H5L_INDEX_NAME; idx_type <=H5L_INDEX_CRT_ORDER; idx_type++) {
/* Loop over operating in different orders */
for(order = H5_ITER_INC; order <=H5_ITER_DEC; order++) {
/* Loop over using index for creation order value */
for(use_index = FALSE; use_index <= TRUE; use_index++) {
/* Print appropriate test message */
if(idx_type == H5L_INDEX_CRT_ORDER) {
if(order == H5_ITER_INC) {
if(use_index)
TESTING("iterating over links by creation order index in increasing order w/creation order index")
else
TESTING("iterating over links by creation order index in increasing order w/o creation order index")
} /* end if */
else {
if(use_index)
TESTING("iterating over links by creation order index in decreasing order w/creation order index")
else
TESTING("iterating over links by creation order index in decreasing order w/o creation order index")
} /* end else */
} /* end if */
else {
if(order == H5_ITER_INC) {
if(use_index)
TESTING("iterating over links by name index in increasing order w/creation order index")
else
TESTING("iterating over links by name index in increasing order w/o creation order index")
} /* end if */
else {
if(use_index)
TESTING("iterating over links by name index in decreasing order w/creation order index")
else
TESTING("iterating over links by name index in decreasing order w/o creation order index")
} /* end else */
} /* end else */
/* Create file */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Create group creation property list */
if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR
/* Set creation order tracking & indexing on group */
if(use_index)
if(H5Pset_creation_order_index(gcpl_id, TRUE) < 0) TEST_ERROR
if(H5Pset_creation_order_tracking(gcpl_id, TRUE) < 0) TEST_ERROR
/* Create group with creation order tracking on */
if((group_id = H5Gcreate_expand(file_id, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Llink(file_id, CORDER_GROUP_NAME, group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* Query the group creation properties */
if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR
/* Check for iteration on empty group */
H5E_BEGIN_TRY {
ret = H5Literate(group_id, ".", idx_type, order, NULL, link_iterate_cb, NULL, H5P_DEFAULT);
} H5E_END_TRY;
if(ret >= 0) TEST_ERROR
#ifdef QAK
/* Create several links, up to limit of compact form */
for(u = 0; u < max_compact; u++) {
hid_t group_id2; /* Group ID */
/* Make name for link */
sprintf(objname, "filler %02u", u);
/* Create hard link, with group object */
if((group_id2 = H5Gcreate(group_id, objname, (size_t)0)) < 0) TEST_ERROR
if(H5Gclose(group_id2) < 0) TEST_ERROR
/* Verify link information for new link */
if(link_info_by_idx_check(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) TEST_ERROR
} /* end for */
/* Verify state of group (compact) */
if(H5G_has_links_test(group_id, NULL) != TRUE) TEST_ERROR
/* Check for out of bound deletion */
H5E_BEGIN_TRY {
ret = H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT);
} H5E_END_TRY;
if(ret >= 0) TEST_ERROR
/* Delete links from compact group */
for(u = 0; u < (max_compact - 1); u++) {
/* Delete first link in appropriate order */
if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR
/* Verify the link information for first link in appropriate order */
HDmemset(&linfo, 0, sizeof(linfo));
if(H5Lget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR
if(order == H5_ITER_INC) {
if(linfo.corder != (u + 1)) TEST_ERROR
} /* end if */
else {
if(linfo.corder != (max_compact - (u + 2))) TEST_ERROR
} /* end else */
/* Verify the name for first link in appropriate order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
if(H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR
if(order == H5_ITER_INC)
sprintf(objname, "filler %02u", (u + 1));
else
sprintf(objname, "filler %02u", (max_compact - (u + 2)));
if(HDstrcmp(objname, tmpname)) TEST_ERROR
} /* end for */
/* Delete last link */
if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR
/* Verify state of group (empty) */
if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR
/* Create more links, to push group into dense form */
for(u = 0; u < (max_compact * 2); u++) {
hid_t group_id2; /* Group ID */
/* Make name for link */
sprintf(objname, "filler %02u", u);
/* Create hard link, with group object */
if((group_id2 = H5Gcreate(group_id, objname, (size_t)0)) < 0) TEST_ERROR
if(H5Gclose(group_id2) < 0) TEST_ERROR
/* Verify state of group (dense) */
if(u >= max_compact)
if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR
/* Verify link information for new link */
if(link_info_by_idx_check(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) TEST_ERROR
} /* end for */
/* Check for out of bound deletion again */
H5E_BEGIN_TRY {
ret = H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT);
} H5E_END_TRY;
if(ret >= 0) TEST_ERROR
/* Delete links from dense group, in appropriate order */
for(u = 0; u < ((max_compact * 2) - 1); u++) {
/* Delete first link in appropriate order */
if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR
/* Verify the link information for first link in appropriate order */
HDmemset(&linfo, 0, sizeof(linfo));
if(H5Lget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR
if(order == H5_ITER_INC) {
if(linfo.corder != (u + 1)) TEST_ERROR
} /* end if */
else {
if(linfo.corder != ((max_compact * 2) - (u + 2))) TEST_ERROR
} /* end else */
/* Verify the name for first link in appropriate order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
if(H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR
if(order == H5_ITER_INC)
sprintf(objname, "filler %02u", (u + 1));
else
sprintf(objname, "filler %02u", ((max_compact * 2) - (u + 2)));
if(HDstrcmp(objname, tmpname)) TEST_ERROR
} /* end for */
/* Delete last link */
if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR
/* Verify state of group (empty) */
if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR
if(H5G_is_new_dense_test(group_id) == TRUE) TEST_ERROR
/* Check for deletion on empty group again */
H5E_BEGIN_TRY {
ret = H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT);
} H5E_END_TRY;
if(ret >= 0) TEST_ERROR
/* Delete links in middle */
/* Create more links, to push group into dense form */
for(u = 0; u < (max_compact * 2); u++) {
hid_t group_id2; /* Group ID */
/* Make name for link */
sprintf(objname, "filler %02u", u);
/* Create hard link, with group object */
if((group_id2 = H5Gcreate(group_id, objname, (size_t)0)) < 0) TEST_ERROR
if(H5Gclose(group_id2) < 0) TEST_ERROR
/* Verify state of group (dense) */
if(u >= max_compact)
if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR
/* Verify link information for new link */
if(link_info_by_idx_check(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) TEST_ERROR
} /* end for */
/* Delete every other link from dense group, in appropriate order */
for(u = 0; u < max_compact; u++) {
/* Delete link */
if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT) < 0) TEST_ERROR
/* Verify the link information for current link in appropriate order */
HDmemset(&linfo, 0, sizeof(linfo));
if(H5Lget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)u, &linfo, H5P_DEFAULT) < 0) TEST_ERROR
if(order == H5_ITER_INC) {
if(linfo.corder != ((u * 2) + 1)) TEST_ERROR
} /* end if */
else {
if(linfo.corder != ((max_compact * 2) - ((u * 2) + 2))) TEST_ERROR
} /* end else */
/* Verify the name for current link in appropriate order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
if(H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR
if(order == H5_ITER_INC)
sprintf(objname, "filler %02u", ((u * 2) + 1));
else
sprintf(objname, "filler %02u", ((max_compact * 2) - ((u * 2) + 2)));
if(HDstrcmp(objname, tmpname)) TEST_ERROR
} /* end for */
/* Delete remaining links from dense group, in appropriate order */
for(u = 0; u < (max_compact - 1); u++) {
/* Delete link */
if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR
/* Verify the link information for first link in appropriate order */
HDmemset(&linfo, 0, sizeof(linfo));
if(H5Lget_info_by_idx(group_id, ".", idx_type, order, (hsize_t)0, &linfo, H5P_DEFAULT) < 0) TEST_ERROR
if(order == H5_ITER_INC) {
if(linfo.corder != ((u * 2) + 3)) TEST_ERROR
} /* end if */
else {
if(linfo.corder != ((max_compact * 2) - ((u * 2) + 4))) TEST_ERROR
} /* end else */
/* Verify the name for first link in appropriate order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
if(H5Lget_name_by_idx(group_id, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR
if(order == H5_ITER_INC)
sprintf(objname, "filler %02u", ((u * 2) + 3));
else
sprintf(objname, "filler %02u", ((max_compact * 2) - ((u * 2) + 4)));
if(HDstrcmp(objname, tmpname)) TEST_ERROR
} /* end for */
/* Delete last link */
if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR
/* Verify state of group (empty) */
if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR
if(H5G_is_new_dense_test(group_id) == TRUE) TEST_ERROR
#endif /* QAK */
/* Close the group */
if(H5Gclose(group_id) < 0) TEST_ERROR
/* Close the group creation property list */
if(H5Pclose(gcpl_id) < 0) TEST_ERROR
/* Close the file */
if(H5Fclose(file_id) < 0) TEST_ERROR
PASSED();
} /* end for */
} /* end for */
} /* end for */
return 0;
error:
H5E_BEGIN_TRY {
H5Pclose(gcpl_id);
H5Gclose(group_id);
H5Fclose(file_id);
} H5E_END_TRY;
return -1;
} /* end link_iterate() */
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
@ -7092,7 +7426,7 @@ main(void)
} /* end for */ } /* end for */
#else /* QAK */ #else /* QAK */
HDfprintf(stderr, "Uncomment tests!\n"); HDfprintf(stderr, "Uncomment tests!\n");
nerrors += delete_by_idx_old(fapl) < 0 ? 1 : 0; nerrors += link_iterate(fapl2) < 0 ? 1 : 0;
#endif /* QAK */ #endif /* QAK */
/* Close 2nd FAPL */ /* Close 2nd FAPL */