diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5B.c | 8 | ||||
-rw-r--r-- | src/H5B2int.c | 2 | ||||
-rw-r--r-- | src/H5B2private.h | 8 | ||||
-rw-r--r-- | src/H5Bprivate.h | 8 | ||||
-rw-r--r-- | src/H5Distore.c | 32 | ||||
-rw-r--r-- | src/H5Edefin.h | 15 | ||||
-rw-r--r-- | src/H5Einit.h | 59 | ||||
-rw-r--r-- | src/H5Epubgen.h | 26 | ||||
-rw-r--r-- | src/H5Eterm.h | 17 | ||||
-rw-r--r-- | src/H5G.c | 71 | ||||
-rw-r--r-- | src/H5Gcompact.c | 83 | ||||
-rw-r--r-- | src/H5Gdense.c | 98 | ||||
-rw-r--r-- | src/H5Gdeprec.c | 71 | ||||
-rw-r--r-- | src/H5Glink.c | 150 | ||||
-rw-r--r-- | src/H5Gnode.c | 178 | ||||
-rw-r--r-- | src/H5Gobj.c | 6 | ||||
-rw-r--r-- | src/H5Gpkg.h | 88 | ||||
-rw-r--r-- | src/H5Gpublic.h | 6 | ||||
-rw-r--r-- | src/H5Gstab.c | 93 | ||||
-rw-r--r-- | src/H5O.c | 12 | ||||
-rw-r--r-- | src/H5Olinfo.c | 6 | ||||
-rw-r--r-- | src/H5Oprivate.h | 8 | ||||
-rw-r--r-- | src/H5T.c | 6 | ||||
-rw-r--r-- | src/H5Tpkg.h | 8 | ||||
-rw-r--r-- | src/H5err.txt | 2 | ||||
-rw-r--r-- | src/H5public.h | 8 |
26 files changed, 589 insertions, 480 deletions
@@ -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 * application callback. */ - for (u=0, ret_value=H5B_ITER_CONT; u<nchildren && !ret_value; u++) { - ret_value = (*op)(f, dxpl_id, key+u*type->sizeof_nkey, - child[u], key+(u+1)*type->sizeof_nkey, udata); - if (ret_value<0) + for(u = 0, ret_value = H5_ITER_CONT; u < nchildren && !ret_value; u++) { + ret_value = (*op)(f, dxpl_id, key + (u * type->sizeof_nkey), + child[u], key + ((u + 1) * type->sizeof_nkey), udata); + if(ret_value < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iterator function failed") } /* end for */ } /* end for */ diff --git a/src/H5B2int.c b/src/H5B2int.c index 879c12d..96d7e75e8 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -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 */ H5B2_node_ptr_t *node_ptrs = NULL; /* Pointers to node's node pointers */ 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) diff --git a/src/H5B2private.h b/src/H5B2private.h index 48d0cbd..aa4bb12 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -36,14 +36,6 @@ /* 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 */ diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index c94d1a6..f79ea57 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -53,14 +53,6 @@ #define H5B_MAGIC "TREE" /*tree node 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 */ /****************************/ diff --git a/src/H5Distore.c b/src/H5Distore.c index b857e0c..d4a9708 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -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; - FUNC_LEAVE_NOAPI(H5B_ITER_CONT) + FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* 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; unsigned rank; 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); @@ -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); } /* end if */ - FUNC_LEAVE_NOAPI(H5B_ITER_CONT) + FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* 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; 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) @@ -1033,10 +1033,10 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key, if(nbytes > buf_size) { /* Re-allocate memory for copying the chunk */ 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(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) 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 */ 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 */ if(is_compressed && (is_vlen || fix_ref)) { 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) - 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 */ /* 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 */ 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 */ 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 */ 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 */ 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 */ else if(fix_ref) { /* 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(H5Z_pipeline(pline, 0, &(udata_dst.common.key.filter_mask), edc_read, 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->buf = buf; 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 */ 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 */ 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) - 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: 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; const H5D_istore_key_t *lt_key = (const H5D_istore_key_t *)_lt_key; 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 * 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 */ 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; } /* end if */ diff --git a/src/H5Edefin.h b/src/H5Edefin.h index f54228e..35579ea 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -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_NOTREGISTERED_g = FAIL; /* Link class not registered */ hid_t H5E_CANTMOVE_g = FAIL; /* Move callback returned error */ +hid_t H5E_CANTSORT_g = FAIL; /* Can't sort objects */ /* Parallel MPI errors */ 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_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 */ hid_t H5E_NOTFOUND_g = FAIL; /* Object not found */ 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_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 */ hid_t H5E_CANTCONVERT_g = FAIL; /* Can't convert datatypes */ hid_t H5E_BADSIZE_g = FAIL; /* Bad size for object */ diff --git a/src/H5Einit.h b/src/H5Einit.h index 2da01ba..8b2429a 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -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") if((H5E_CANTMOVE_g = H5I_register(H5I_ERROR_MSG, msg))<0) 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 */ 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) 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 */ assert(H5E_NOTFOUND_g==(-1)); 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) 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 */ assert(H5E_CANTCONVERT_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't convert datatypes"))==NULL) diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index 7c517cf..ccd1d52 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -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_NOTREGISTERED (H5OPEN H5E_NOTREGISTERED_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_NLINKS_g; /* Too many soft links in path */ 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_CANTSORT_g; /* Can't sort objects */ /* Parallel MPI errors */ #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_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 */ #define H5E_NOTFOUND (H5OPEN H5E_NOTFOUND_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_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 */ #define H5E_CANTCONVERT (H5OPEN H5E_CANTCONVERT_g) #define H5E_BADSIZE (H5OPEN H5E_BADSIZE_g) diff --git a/src/H5Eterm.h b/src/H5Eterm.h index a188ab4..1c4e762 100644 --- a/src/H5Eterm.h +++ b/src/H5Eterm.h @@ -169,7 +169,8 @@ H5E_CANTRESIZE_g= H5E_TRAVERSE_g= H5E_NLINKS_g= H5E_NOTREGISTERED_g= -H5E_CANTMOVE_g= +H5E_CANTMOVE_g= +H5E_CANTSORT_g= /* Parallel MPI errors */ H5E_MPI_g= @@ -184,6 +185,13 @@ H5E_CANTNEXT_g= H5E_BADSELECT_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 */ H5E_NOTFOUND_g= H5E_EXISTS_g= @@ -197,13 +205,6 @@ H5E_CANTLIST_g= H5E_CANTMODIFY_g= H5E_CANTREMOVE_g= -/* Argument errors */ -H5E_UNINITIALIZED_g= -H5E_UNSUPPORTED_g= -H5E_BADTYPE_g= -H5E_BADRANGE_g= -H5E_BADVALUE_g= - /* Datatype conversion errors */ H5E_CANTCONVERT_g= H5E_BADSIZE_g= (-1); @@ -549,77 +549,6 @@ done: /*------------------------------------------------------------------------- - * 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 * * Purpose: Returns the number of objects in the group. It iterates diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index cebae1e..c005815 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -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 */ 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) @@ -97,7 +97,7 @@ H5G_compact_build_table_cb(const void *_mesg, unsigned UNUSED idx, void *_udata) /* Copy link message into table */ if(NULL == H5O_copy(H5O_LINK_ID, lnk, &(udata->ltable->lnks[udata->curr_lnk]))) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5O_ITER_ERROR, "can't copy link message") + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") /* Increment current link entry to operate on */ 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) { 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) 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") /* Sort link table in correct iteration order */ - if(idx_type == H5L_INDEX_NAME) { - if(order == H5_ITER_INC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_name_inc); - else if(order == H5_ITER_DEC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_name_dec); - else - HDassert(order == H5_ITER_NATIVE); - } /* end if */ - else { - HDassert(idx_type == H5L_INDEX_CRT_ORDER); - if(order == H5_ITER_INC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_corder_inc); - else if(order == H5_ITER_DEC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_corder_dec); - else - HDassert(order == H5_ITER_NATIVE); - } /* end else */ + if(H5G_link_sort_table(ltable, idx_type, order) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting link messages") } /* end if */ else 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 */ 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) @@ -361,10 +347,10 @@ H5G_compact_remove_common_cb(const void *_mesg, unsigned UNUSED idx, void *_udat if(HDstrcmp(lnk->name, udata->name) == 0) { /* 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) - 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 */ - HGOTO_DONE(H5O_ITER_STOP) + HGOTO_DONE(H5_ITER_STOP) } /* end if */ done: @@ -478,12 +464,11 @@ done: */ herr_t H5G_compact_iterate(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_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) { H5G_link_table_t ltable = {0, NULL}; /* Link table */ - size_t u; /* Local index variable */ - herr_t ret_value; + herr_t ret_value; /* Return value */ 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, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create link message table") - /* Iterate over link messages */ - for(u = 0, ret_value = H5O_ITER_CONT; u < ltable.nlinks && !ret_value; u++) { - 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) + /* Iterate over links in table */ + if((ret_value = H5G_link_iterate_table(<able, skip, last_lnk, gid, lnk_op, op_data)) < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); 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 */ 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) @@ -577,14 +526,14 @@ H5G_compact_lookup_cb(const void *_mesg, unsigned UNUSED idx, void *_udata) if(udata->lnk) { /* Copy link information */ if(NULL == H5O_copy(H5O_LINK_ID, lnk, udata->lnk)) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5O_ITER_ERROR, "can't copy link message") + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") } /* end if */ /* Indicate that the correct link was found */ udata->found = TRUE; /* Stop iteration now */ - HGOTO_DONE(H5O_ITER_STOP) + HGOTO_DONE(H5_ITER_STOP) } /* end if */ 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 */ if(NULL == H5O_copy(H5O_LINK_ID, <able.lnks[n], lnk)) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5O_ITER_ERROR, "can't copy link message") + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy link message") done: /* Release link table */ diff --git a/src/H5Gdense.c b/src/H5Gdense.c index 17a5d68..7fd7883 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -487,7 +487,7 @@ H5G_dense_lookup_cb(const void *_lnk, void *_user_lnk) if(user_lnk) { /* Copy link information */ 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 */ 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 */ 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: if(tmp_lnk) @@ -597,7 +597,7 @@ done: * * 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 * 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; 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 */ - 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) @@ -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 */ if(H5HF_op(bt2_udata->fheap, bt2_udata->dxpl_id, record->id, 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: 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 */ if(NULL == H5O_copy(H5O_LINK_ID, <able.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 */ done: @@ -751,7 +751,7 @@ static herr_t 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 */ - 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) @@ -762,7 +762,7 @@ H5G_dense_build_table_cb(const H5O_link_t *lnk, void *_udata) /* Copy link information */ 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 */ 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") /* Sort link table in correct iteration order */ - if(idx_type == H5L_INDEX_NAME) { - if(order == H5_ITER_INC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_name_inc); - else if(order == H5_ITER_DEC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_name_dec); - else - HDassert(order == H5_ITER_NATIVE); - } /* end if */ - else { - HDassert(idx_type == H5L_INDEX_CRT_ORDER); - if(order == H5_ITER_INC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_corder_inc); - else if(order == H5_ITER_DEC) - HDqsort(ltable->lnks, ltable->nlinks, sizeof(H5O_link_t), H5G_link_cmp_corder_dec); - else - HDassert(order == H5_ITER_NATIVE); - } /* end else */ + if(H5G_link_sort_table(ltable, idx_type, order) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSORT, FAIL, "error sorting link messages") } /* end if */ else ltable->lnks = NULL; @@ -896,7 +881,7 @@ done: * * 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 * 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; 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) @@ -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 */ if(H5HF_op(bt2_udata->fheap, bt2_udata->dxpl_id, record->id, 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 */ 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 */ 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 */ 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, 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 */ 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) @@ -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"); } /* end if */ else { - size_t u; /* Local index variable */ - /* Build the table of links for this group */ if(H5G_dense_build_table(f, dxpl_id, linfo, idx_type, order, <able) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "error building table of links") - /* Iterate over link messages */ - for(u = 0, ret_value = H5B_ITER_CONT; u < ltable.nlinks && !ret_value; u++) { - 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) + /* Iterate over links in table */ + if((ret_value = H5G_link_iterate_table(<able, skip, last_lnk, gid, lnk_op, op_data)) < 0) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); } /* end else */ @@ -1381,7 +1327,7 @@ H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata) /* Decode link information */ 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 */ 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)); if(H5B2_remove(udata->f, udata->dxpl_id, H5G_BT2_CORDER, udata->corder_bt2_addr, &bt2_udata, NULL, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, 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 */ /* 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 */ 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 */ @@ -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 */ if(H5B2_remove(bt2_udata->f, bt2_udata->dxpl_id, other_bt2_class, bt2_udata->other_bt2_addr, &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 */ /* Replace open objects' names */ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 72a5dae..b11ca88 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -675,3 +675,74 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* 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() */ + diff --git a/src/H5Glink.c b/src/H5Glink.c index 0a379d1..b0966d7 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -217,7 +217,7 @@ H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2) */ 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) + H5HL_t *_heap, const H5G_entry_t *ent, const char *name) { 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 */ HDassert(f); HDassert(lnk); + HDassert(H5F_addr_defined(lheap_addr) || _heap); + HDassert(!(H5F_addr_defined(lheap_addr) && _heap)); HDassert(ent); + HDassert(name); /* Set (default) common info for link */ lnk->cset = H5F_DEFAULT_CSET; lnk->corder = 0; lnk->corder_valid = FALSE; /* Creation order not valid for this link */ lnk->name = H5MM_xstrdup(name); + HDassert(lnk->name); /* Object is a symbolic or hard link */ if(ent->type == H5G_CACHED_SLINK) { 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 */ - if(NULL == (heap = H5HL_protect(f, dxpl_id, lheap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read protect link value") + /* Check if the heap pointer was passed in */ + if(!heap) { + /* 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); /* Copy the link value */ lnk->u.soft.name = H5MM_xstrdup(s); - /* Release the local heap */ - 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") + /* Release the local heap, if we locked it */ + if(heap != _heap) + 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 */ 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: 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 */ 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 */ 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 */ 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; /* 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 */ 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 */ dst_lnk->u.hard.addr = new_dst_oloc.addr; @@ -519,6 +527,124 @@ done: /*------------------------------------------------------------------------- + * 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 * * Purpose: Release table containing a list of links for a group diff --git a/src/H5Gnode.c b/src/H5Gnode.c index f05fb90..c2fbad4 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -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 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 */ FUNC_ENTER_NOAPI_NOINIT(H5G_node_debug_key) @@ -778,7 +778,7 @@ done: static int 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 *rt_key = (H5G_node_key_t *) _rt_key; H5HL_t *heap = NULL; @@ -843,7 +843,7 @@ done: static int 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 *rt_key = (H5G_node_key_t *) _rt_key; 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, 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; H5HL_t *heap = NULL; 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 *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; unsigned sn_flags = H5AC__NO_FLAGS_SET, snrt_flags = H5AC__NO_FLAGS_SET; 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 *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; unsigned sn_flags = H5AC__NO_FLAGS_SET; 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, 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; 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 */ H5G_entry_t *ents = NULL; /* Copy of entries in this node */ unsigned u; /* Local index variable */ int ret_value; - FUNC_ENTER_NOAPI(H5G_node_iterate, H5B_ITER_ERROR) + FUNC_ENTER_NOAPI(H5G_node_iterate, H5_ITER_ERROR) /* * 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. */ 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; 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); if(H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) != SUCCEED) { 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 */ sn = NULL; /* Make certain future references will be caught */ /* * 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) --udata->skip; else { size_t n; /* Length of link name */ 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))) - 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); 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 */ if((n + 1) > sizeof(buf)) { + if(s != buf) + H5MM_xfree(s); 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 */ else 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); 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; /* 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 */ 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 */ ret_value = (udata->lnk_op->u.app_op)(udata->group_id, s, &info, udata->op_data); - } /* end if */ + } break; 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 */ /* Convert the entry to a link */ - if(H5G_ent_to_link(f, dxpl_id, &lnk, udata->heap_addr, &ents[u], s) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5B_ITER_ERROR, "unable to convert symbol table entry to link") + if(H5G_ent_to_link(f, dxpl_id, &lnk, udata->heap_addr, NULL, &ents[u], s) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCONVERT, H5_ITER_ERROR, "unable to convert symbol table entry to link") /* Call the library's callback */ ret_value = (udata->lnk_op->u.lib_op)(&lnk, udata->op_data); /* Release memory for link object */ if(H5O_reset(H5O_LINK_ID, &lnk) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, H5B_ITER_ERROR, "unable to release link message") - } /* end if */ + HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, H5_ITER_ERROR, "unable to release link message") + } } /* end switch */ - - /* Free the memory for the name, if we used a dynamically allocated buffer */ - if(s != buf) - H5MM_xfree(s); } /* end else */ /* 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"); 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) - 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) - 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) 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; 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. @@ -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. */ 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; done: 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) } /* 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_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. @@ -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 */ 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 */ 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") /* Indicate that we found the entry we are interested in */ - ret_value = H5B_ITER_STOP; + ret_value = H5_ITER_STOP; } /* end if */ else udata->num_objs += sn->nsyms; done: 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); } /* 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; H5G_node_t *sn = NULL; 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. */ 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 */ 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 */ 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 */ 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 */ 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 */ lnk.type = H5L_TYPE_HARD; @@ -1902,21 +1906,103 @@ 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 */ /* (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) - 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++) */ done: 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) - 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) } /* 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 * * Purpose: Prints debugging information about a symbol table node @@ -1956,7 +2042,7 @@ H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, * B-tree node. */ 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 */ udata.heap_addr = heap_addr; diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 11b9f3d..84819cd 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -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 */ 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) @@ -359,7 +359,7 @@ static herr_t 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 */ - 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) @@ -370,7 +370,7 @@ H5G_obj_stab_to_new_cb(const H5O_link_t *lnk, void *_udata) /* Insert link into group */ /* (Casting away const OK - QAK) */ 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: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 0d57137..b240fb0 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -142,48 +142,46 @@ typedef struct { } u; } 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 * passed through the B-link tree layer to the methods for the objects * 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 */ const char *name; /*points to temporary memory */ haddr_t heap_addr; /*symbol table heap address */ -} H5G_bt_ud_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; +} H5G_bt_common_t; /* * Data exchange structure for symbol table nodes. This structure is * 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 */ - 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 */ -} H5G_bt_ud1_t; +} H5G_bt_ins_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. + * passed through the B-link tree layer to the remove method for entries. */ -typedef struct H5G_bt_ud2_t { +typedef struct H5G_bt_rm_t { /* 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 */ 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 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 * 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 */ - 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 */ void *op_data; /* Data to pass to operator */ /* upward */ -} H5G_bt_ud3_t; +} H5G_bt_lkp_t; /* * Data exchange structure to pass through the B-tree layer for the * H5B_iterate function. */ -typedef struct H5G_bt_it_ud1_t { +typedef struct H5G_bt_it_it_t { /* downward */ hid_t group_id; /*group id to pass to iteration operator */ haddr_t heap_addr; /*symbol table heap address */ @@ -215,7 +213,7 @@ typedef struct H5G_bt_it_ud1_t { /* upward */ 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 */ 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; /* 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 */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ haddr_t heap_addr; /*symbol table heap address */ /* upward */ 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 */ -typedef struct H5G_bt_it_idx2_t { +typedef struct H5G_bt_it_gtbi_t { /* downward */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ /* upward */ 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 */ -typedef struct H5G_bt_it_idx3_t { +typedef struct H5G_bt_it_lbi_t { /* downward */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ haddr_t heap_addr; /*symbol table heap address */ @@ -264,7 +262,17 @@ typedef struct H5G_bt_it_idx3_t { /* upward */ H5O_link_t *lnk; /*link to be returned */ 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 */ /* (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*/, 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 */ /*****************************/ @@ -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); 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); +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 */ +struct H5HL_t; H5_DLL int H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2); H5_DLL int H5G_link_cmp_name_dec(const void *lnk1, const void *lnk2); H5_DLL int H5G_link_cmp_corder_inc(const void *lnk1, const void *lnk2); H5_DLL int H5G_link_cmp_corder_dec(const void *lnk1, const void *lnk2); H5_DLL herr_t H5G_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, 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_copy_file(H5F_t *dst_file, hid_t dxpl_id, const H5O_link_t *_src_lnk, const H5O_loc_t *src_oloc, H5O_link_t *dst_lnk, H5O_copy_t *cpy_info); +H5_DLL herr_t H5G_link_sort_table(H5G_link_table_t *ltable, H5L_index_t idx_type, + H5_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_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, @@ -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, H5_iter_order_t order, hsize_t n); H5_DLL herr_t H5G_compact_iterate(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, - H5L_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_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); H5_DLL herr_t H5G_compact_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, hid_t dxpl_id); diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 9f57a85..d7fc5ea 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -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 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 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 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, hbool_t follow_link, H5G_stat_t *statbuf/*out*/); 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 * 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 int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, 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 } diff --git a/src/H5Gstab.c b/src/H5Gstab.c index a4939f1..c982b6b 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -213,7 +213,7 @@ herr_t H5G_stab_insert_real(H5F_t *f, H5O_stab_t *stab, const char *name, 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 */ 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") 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: 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) { 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 */ 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) { 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 */ hbool_t lnk_copied = FALSE; /* Whether the link was copied */ herr_t ret_value = SUCCEED; /* Return value */ @@ -394,7 +394,7 @@ done: herr_t 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; 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, 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 */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ herr_t ret_value; 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 */ /* ("native" iteration order is increasing for this link storage mechanism) */ 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() */ udata.group_id = gid; 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; /* 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) HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); } /* end if */ else { -HDfprintf(stderr, "%s: Decreasing iteration order for symbol table storage not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_SYM, H5E_UNSUPPORTED, FAIL, "decreasing iteration order for symbol table storage not supported yet") + H5G_bt_it_bt_t udata; /* User data to pass to B-tree callback */ + + /* Build udata to pass through H5B_iterate() to H5G_node_iterate() */ + udata.alloc_nlinks = 0; + udata.heap_addr = stab.heap_addr; + udata.ltable = <able; + + /* 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(<able, 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(<able, skip, last_lnk, gid, lnk_op, op_data)) < 0) + HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed"); } /* end else */ done: + /* Release resources */ + if(ltable.lnks && H5G_link_release_table(<able) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_stab_iterate() */ @@ -536,7 +559,7 @@ done: static herr_t 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 */ size_t name_off; /* Offset of name 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) { 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 */ FUNC_ENTER_NOAPI(H5G_stab_get_name_by_idx, FAIL) @@ -663,7 +686,7 @@ done: static herr_t 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 */ 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) { 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 */ 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) { /* Convert the entry to a link */ 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") } /* end if */ @@ -799,7 +822,7 @@ herr_t H5G_stab_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, 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 */ H5O_stab_t stab; /* Symbol table message */ herr_t ret_value = SUCCEED; /* Return value */ @@ -854,13 +877,9 @@ done: static herr_t 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; - H5HL_t *heap; /* Pointer to local heap for group */ - size_t name_off; /* Offset of name in heap */ + H5G_bt_it_lbi_t *udata = (H5G_bt_it_lbi_t *)_udata; + H5HL_t *heap = NULL; /* Pointer to local heap for group */ 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 */ 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(udata); - /* Get name offset in heap */ - name_off = ent->name_off; - /* Pin the heap down in memory */ 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") /* 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); - 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 */ - 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") udata->found = TRUE; done: - /* Free the memory for the name, if we used a dynamically allocated buffer */ - if(s && s != buf) - H5MM_xfree(s); + /* Unlock the heap */ + if(heap && H5HL_unprotect(udata->common.f, udata->common.dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name") FUNC_LEAVE_NOAPI(ret_value) } /* 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, 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 */ herr_t ret_value = SUCCEED; /* Return value */ @@ -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 */ 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) @@ -2441,12 +2441,12 @@ H5O_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, if(udata->op) { /* Call the iterator callback */ 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 */ else { /* If there's no callback routine, does the sequence # match? */ if((int)sequence == udata->sequence || H5O_ALL == udata->sequence) - try_remove = H5O_ITER_STOP; + try_remove = H5_ITER_STOP; } /* end else */ /* Try removing the message, if indicated */ @@ -2460,7 +2460,7 @@ H5O_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, else { /* Convert message into a null message */ if(H5O_release_mesg(udata->f, udata->dxpl_id, oh, mesg, TRUE, udata->adj_link) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, 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 */ *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 */ if(udata->sequence == H5O_FIRST || udata->sequence != H5O_ALL) - HGOTO_DONE(H5O_ITER_STOP) + HGOTO_DONE(H5_ITER_STOP) } /* end if */ 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 sequence; /* Relative index of current message for messages of type */ 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) diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c index bedbcd1..297ba06 100644 --- a/src/H5Olinfo.c +++ b/src/H5Olinfo.c @@ -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_link_t dst_lnk; /* Destination link to insert */ 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) @@ -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) */ if(H5G_link_copy_file(udata->dst_oloc->file, udata->dxpl_id, src_lnk, 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; /* 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) */ 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: /* Check if the destination link has been initialized */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 45c5eec..6570344 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -353,14 +353,6 @@ typedef struct H5O_stab_t { haddr_t heap_addr; /*address of name heap */ } 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 herr_t (*H5O_operator_t)(const void *mesg/*in*/, unsigned idx, void *operator_data/*in,out*/); @@ -1207,7 +1207,7 @@ H5T_init_interface(void) /* 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_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); #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_dbl", native_ullong, native_double, H5T_conv_ullong_double, H5AC_dxpl_id, FALSE); #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); #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, "dbl_llong", native_double, native_llong, H5T_conv_double_llong, H5AC_dxpl_id, FALSE); #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); #endif /* H5T_CONV_INTERNAL_LDOUBLE_LLONG */ diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 0d70c69..f8f03dc 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -102,7 +102,7 @@ /* Define an internal macro for converting long long to long double. Mac OS 10.4 gives some * 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) #define H5T_CONV_INTERNAL_LLONG_LDOUBLE 1 #endif @@ -121,7 +121,7 @@ * compiler tries to do the conversion. For Cygwin, compiler doesn't do rounding correctly. * 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 && \ - 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) #define H5T_CONV_INTERNAL_ULLONG_LDOUBLE 1 #endif @@ -151,7 +151,7 @@ * 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. */ #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) #define H5T_CONV_INTERNAL_LDOUBLE_LLONG 1 #endif @@ -170,7 +170,7 @@ * incorrect conversions. Mac OS 10.4 gives incorrect conversions. HP-UX 11.00 compiler generates * floating exception. */ #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) #define H5T_CONV_INTERNAL_LDOUBLE_ULLONG 1 #else diff --git a/src/H5err.txt b/src/H5err.txt index 410fd52..9fe7e60 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -219,7 +219,7 @@ MINOR, LINK, H5E_TRAVERSE, Link traversal failure MINOR, LINK, H5E_NLINKS, Too many soft links in path MINOR, LINK, H5E_NOTREGISTERED, Link class not registered MINOR, LINK, H5E_CANTMOVE, Move callback returned error - +MINOR, LINK, H5E_CANTSORT, Can't sort objects # Parallel MPI errors MINOR, MPI, H5E_MPI, Some MPI function failed diff --git a/src/H5public.h b/src/H5public.h index c45e1d1..46bbf3c 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -236,6 +236,14 @@ typedef enum { H5_ITER_N /* Number of iteration orders */ } 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 */ H5_DLL herr_t H5open(void); H5_DLL herr_t H5close(void); |