/*------------------------------------------------------------------------- * Function: H5O_drvinfo_decode * * Purpose: Decode a shared message table message and return a pointer * to a newly allocated H5O_drvinfo_t struct. * * Return: Success: Ptr to new message in native struct. * Failure: NULL * * Programmer: Quincey Koziol * Mar 1, 2007 * *------------------------------------------------------------------------- */ static void * H5O_drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5O_drvinfo_t *mesg; /* Native message */ void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity check */ HDassert(f); HDassert(p); /* Version of message */ if(*p++ != H5O_DRVINFO_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ if(NULL == (mesg = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for driver info message") /* Retrieve driver name */ HDmemcpy(mesg->name, p, 8); mesg->name[8] = '\0'; p += 8; /* Decode buffer size */ UINT16DECODE(p, mesg->len); HDassert(mesg->len); /* Allocate space for buffer */ if(NULL == (mesg->buf = (uint8_t *)H5MM_malloc(mesg->len))) { mesg = (H5O_drvinfo_t *)H5MM_xfree(mesg); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for driver info buffer") } /* end if */
/*------------------------------------------------------------------------- * Function: H5Pget_preserve * * Purpose: The inverse of H5Pset_preserve() * * Return: Success: TRUE or FALSE * * Failure: Negative * * Programmer: Robb Matzke * Tuesday, March 17, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int H5Pget_preserve(hid_t plist_id) { H5T_bkg_t need_bkg; /* Background value */ H5P_genplist_t *plist; /* Property list pointer */ int ret_value; /* return value */ FUNC_ENTER_API(H5Pget_preserve, FAIL); H5TRACE1("Is","i",plist_id); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ if (H5P_get(plist,H5D_XFER_BKGR_BUF_TYPE_NAME,&need_bkg)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); /* Set return value */ ret_value= need_bkg ? TRUE : FALSE; done: FUNC_LEAVE_API(ret_value); }
/*------------------------------------------------------------------------- * Function: H5Pset_sizes * * Purpose: Sets file size-of addresses and sizes. PLIST_ID should be a * file creation property list. A value of zero causes the * property to not change. * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Tuesday, January 6, 1998 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_sizes, FAIL); H5TRACE3("e","izz",plist_id,sizeof_addr,sizeof_size); /* Check arguments */ if (sizeof_addr) { if (sizeof_addr != 2 && sizeof_addr != 4 && sizeof_addr != 8 && sizeof_addr != 16) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file haddr_t size is not valid"); } if (sizeof_size) { if (sizeof_size != 2 && sizeof_size != 4 && sizeof_size != 8 && sizeof_size != 16) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file size_t size is not valid"); } /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set value */ if (sizeof_addr) if(H5P_set(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sizeof_addr) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for an address"); if (sizeof_size) if(H5P_set(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for object "); done: FUNC_LEAVE_API(ret_value); }
/*------------------------------------------------------------------------- * Function: H5Pget_istore_k * * Purpose: Queries the 1/2 rank of an indexed storage B-tree. See * H5Pset_istore_k() for details. The argument IK may be the * null pointer. * * Return: Success: Non-negative, size returned through IK * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * * Raymond Lu, Oct 14, 2001 * Changed to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out */ ) { unsigned btree_k[H5B_NUM_BTREE_ID]; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_istore_k, FAIL); H5TRACE2("e","ix",plist_id,ik); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ if (ik) { if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree interanl nodes"); *ik = btree_k[H5B_ISTORE_ID]; } done: FUNC_LEAVE_API(ret_value); }
/*------------------------------------------------------------------------- * Function: H5Pset_edc_check * * Purpose: Enable or disable error-detecting for a dataset reading * process. This error-detecting algorithm is whichever * user chooses earlier. This function cannot control * writing process. * * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Jan 3, 2003 * * Modifications: * *------------------------------------------------------------------------- */ herr_t H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_edc_check, FAIL); H5TRACE2("e","iZe",plist_id,check); /* Check argument */ if (check != H5Z_ENABLE_EDC && check != H5Z_DISABLE_EDC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid value"); /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Update property list */ if (H5P_set(plist,H5D_XFER_EDC_NAME,&check)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value"); done: FUNC_LEAVE_API(ret_value); }
/*------------------------------------------------------------------------- * Function: H5O_shared_read * * Purpose: Reads a message referred to by a shared message. * * Return: Success: Ptr to message in native format. The message * should be freed by calling H5O_msg_reset(). * * Failure: NULL * * Programmer: Quincey Koziol * [email protected] * Sep 24 2003 * *------------------------------------------------------------------------- */ static void * H5O_shared_read(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned *ioflags, const H5O_shared_t *shared, const H5O_msg_class_t *type) { H5HF_t *fheap = NULL; H5WB_t *wb = NULL; /* Wrapped buffer for attribute data */ uint8_t mesg_buf[H5O_MESG_BUF_SIZE]; /* Buffer for deserializing messages */ void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_read) /* check args */ HDassert(f); HDassert(shared); HDassert(type); HDassert(type->share_flags & H5O_SHARE_IS_SHARABLE); /* This message could have a heap ID (SOHM) or the address of an object * header on disk (named datatype) */ HDassert(H5O_IS_STORED_SHARED(shared->type)); /* Check for implicit shared object header message */ if(shared->type == H5O_SHARE_TYPE_SOHM) { haddr_t fheap_addr; /* Address of SOHM heap */ uint8_t *mesg_ptr; /* Pointer to raw message in heap */ size_t mesg_size; /* Size of message */ /* Retrieve the fractal heap address for shared messages */ if(H5SM_get_fheap_addr(f, dxpl_id, type->id, &fheap_addr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "can't get fheap address for shared messages") /* Open the fractal heap */ if(NULL == (fheap = H5HF_open(f, dxpl_id, fheap_addr))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open fractal heap") /* Get the size of the message in the heap */ if(H5HF_get_obj_len(fheap, dxpl_id, &(shared->u.heap_id), &mesg_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "can't get message size from fractal heap.") /* Wrap the local buffer for serialized message */ if(NULL == (wb = H5WB_wrap(mesg_buf, sizeof(mesg_buf)))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough for message */ if(NULL == (mesg_ptr = (uint8_t *)H5WB_actual(wb, mesg_size))) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "can't get actual buffer") /* Retrieve the message from the heap */ if(H5HF_read(fheap, dxpl_id, &(shared->u.heap_id), mesg_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "can't read message from fractal heap.") /* Decode the message */ if(NULL == (ret_value = (type->decode)(f, dxpl_id, open_oh, 0, ioflags, mesg_ptr))) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't decode shared message.") } /* end if */
/*------------------------------------------------------------------------- * Function: H5O_ainfo_copy_file * * Purpose: Copies a message from _MESG to _DEST in file * * Return: Success: Ptr to _DEST * Failure: NULL * * Programmer: Peter Cao * July 18, 2007 * *------------------------------------------------------------------------- */ static void * H5O_ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata, hid_t dxpl_id) { H5O_ainfo_t *ainfo_src = (H5O_ainfo_t *)mesg_src; H5O_ainfo_t *ainfo_dst = NULL; void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* check args */ HDassert(file_src); HDassert(ainfo_src); HDassert(file_dst); HDassert(cpy_info); HDassert(!cpy_info->copy_without_attr); /* Allocate space for the destination message */ if(NULL == (ainfo_dst = H5FL_MALLOC(H5O_ainfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the top level of the information */ *ainfo_dst = *ainfo_src; if(H5F_addr_defined(ainfo_src->fheap_addr)) { /* Prepare to copy dense attributes - actual copy in post_copy */ /* Set copied metadata tag */ H5_BEGIN_TAG(dxpl_id, H5AC__COPIED_TAG, NULL); if(H5A_dense_create(file_dst, dxpl_id, ainfo_dst) < 0) HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINIT, NULL, "unable to create dense storage for attributes") /* Reset metadata tag */ H5_END_TAG(NULL); } /* end if */ /* Set return value */ ret_value = ainfo_dst; done: /* Release destination attribute information on failure */ if(!ret_value && ainfo_dst) ainfo_dst = H5FL_FREE(H5O_ainfo_t, ainfo_dst); FUNC_LEAVE_NOAPI(ret_value) } /* H5O_ainfo_copy_file() */
/*------------------------------------------------------------------------- * Function: H5G_normalize * * Purpose: Returns a pointer to a new string which has duplicate and * trailing slashes removed from it. * * Return: Success: Ptr to normalized name. * Failure: NULL * * Programmer: Quincey Koziol * Saturday, August 16, 2003 * *------------------------------------------------------------------------- */ char * H5G_normalize(const char *name) { char *norm; /* Pointer to the normalized string */ size_t s,d; /* Positions within the strings */ unsigned last_slash; /* Flag to indicate last character was a slash */ char *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_normalize) /* Sanity check */ HDassert(name); /* Duplicate the name, to return */ if(NULL == (norm = H5MM_strdup(name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for normalized string") /* Walk through the characters, omitting duplicated '/'s */ s = d = 0; last_slash = 0; while(name[s] != '\0') { if(name[s] == '/') if(last_slash) ; else { norm[d++] = name[s]; last_slash = 1; } /* end else */ else { norm[d++] = name[s]; last_slash = 0; } /* end else */ s++; } /* end while */ /* Terminate normalized string */ norm[d] = '\0'; /* Check for final '/' on normalized name & eliminate it */ if(d > 1 && last_slash) norm[d - 1] = '\0'; /* Set return value */ ret_value = norm; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_normalize() */
/*------------------------------------------------------------------------- * Function: H5HG_load * * Purpose: Loads a global heap collection from disk. * * Return: Success: Ptr to a global heap collection. * * Failure: NULL * * Programmer: Robb Matzke * Friday, March 27, 1998 * *------------------------------------------------------------------------- */ static H5HG_heap_t * H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, void UNUSED * udata2) { H5HG_heap_t *heap = NULL; uint8_t *p = NULL; size_t nalloc, need; size_t max_idx = 0; /* The maximum index seen */ H5HG_heap_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(H5HG_load, NULL) /* check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); HDassert(!udata1); HDassert(!udata2); /* Read the initial 4k page */ if(NULL == (heap = H5FL_CALLOC(H5HG_heap_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") heap->addr = addr; if(NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, (size_t)H5HG_MINSIZE))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if(H5F_block_read(f, H5FD_MEM_GHEAP, addr, (size_t)H5HG_MINSIZE, dxpl_id, heap->chunk) < 0) HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "unable to read global heap collection") /* Magic number */ if(HDmemcmp(heap->chunk, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad global heap collection signature") p = heap->chunk + H5_SIZEOF_MAGIC; /* Version */ if(H5HG_VERSION != *p++) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "wrong version number in global heap") /* Reserved */ p += 3; /* Size */ H5F_DECODE_LENGTH(f, p, heap->size); HDassert(heap->size >= H5HG_MINSIZE); /* * If we didn't read enough in the first try, then read the rest of the * collection now. */ if(heap->size > H5HG_MINSIZE) { haddr_t next_addr = addr + (hsize_t)H5HG_MINSIZE; if(NULL == (heap->chunk = H5FL_BLK_REALLOC(gheap_chunk, heap->chunk, heap->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if(H5F_block_read(f, H5FD_MEM_GHEAP, next_addr, (heap->size - H5HG_MINSIZE), dxpl_id, heap->chunk + H5HG_MINSIZE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "unable to read global heap collection") } /* end if */
/*-------------------------------------------------------------------------- NAME H5S_none_deserialize PURPOSE Deserialize the current selection from a user-provided buffer. USAGE herr_t H5S_none_deserialize(space, buf) H5S_t *space; IN/OUT: Dataspace pointer to place selection into uint8 *buf; IN: Buffer to retrieve serialized selection from RETURNS Non-negative on success/Negative on failure DESCRIPTION Deserializes the current selection into a buffer. (Primarily for retrieving from disk). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ static herr_t H5S_none_deserialize (H5S_t *space, const uint8_t UNUSED *buf) { herr_t ret_value; /* return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_none_deserialize); assert(space); /* Change to "none" selection */ if((ret_value=H5S_select_none(space))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection"); done: FUNC_LEAVE_NOAPI(ret_value); } /* H5S_none_deserialize() */
/*-------------------------------------------------------------------------- NAME H5R__init_package -- Initialize interface-specific information USAGE herr_t H5R__init_package() RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ herr_t H5R__init_package(void) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Initialize the atom group for the file IDs */ if (H5I_register_type(H5I_REFERENCE_CLS) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to initialize interface") /* Mark "top" of interface as initialized, too */ H5R_top_package_initialize_s = TRUE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__init_package() */
/*------------------------------------------------------------------------- * Function: H5A_compact_build_table * * Purpose: Builds a table containing a sorted list of attributes for * an object * * Note: Used for building table of attributes in non-native iteration * order for an index * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Dec 18, 2006 * *------------------------------------------------------------------------- */ herr_t H5A_compact_build_table(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_index_t idx_type, H5_iter_order_t order, H5A_attr_table_t *atable) { H5A_compact_bt_ud_t udata; /* User data for iteration callback */ H5O_mesg_operator_t op; /* Wrapper for operator */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity check */ HDassert(f); HDassert(oh); HDassert(atable); /* Initialize table */ atable->attrs = NULL; atable->nattrs = 0; /* Set up user data for iteration */ udata.f = f; udata.dxpl_id = dxpl_id; udata.atable = atable; udata.curr_attr = 0; udata.bogus_crt_idx = (hbool_t)((oh->version == H5O_VERSION_1 || !(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) ? TRUE : FALSE); /* Iterate over existing attributes, checking for attribute with same name */ op.op_type = H5O_MESG_OP_LIB; op.u.lib_op = H5A_compact_build_table_cb; if(H5O_msg_iterate_real(f, oh, H5O_MSG_ATTR, &op, &udata, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error building attribute table") /* Correct # of attributes in table */ atable->nattrs = udata.curr_attr; /* Don't sort an empty table. */ if(atable->nattrs > 0) { /* Sort attribute table in correct iteration order */ if(H5A_attr_sort_table(atable, idx_type, order) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSORT, FAIL, "error sorting attribute table") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_compact_build_table() */
/*------------------------------------------------------------------------- * Function: H5Pset_fapl_windows * * Purpose: Modify the file access property list to use the H5FD_WINDOWS * driver defined in this source file. There are no driver * specific properties. * * NOTE: The Windows VFD was merely a merge of the SEC2 and STDIO drivers * so it has been retired. Selecting the Windows VFD will actually * set the SEC2 VFD (though for backwards compatibility, we'll keep * the H5FD_WINDOWS symbol). * * * Return: Non-negative on success/Negative on failure * * Programmer: Dana Robinson * October 10, 2011 * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_windows(hid_t fapl_id) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", fapl_id); if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") ret_value = H5P_set_driver(plist, H5FD_WINDOWS, NULL); done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_windows() */
/*------------------------------------------------------------------------- * Function: H5HF_man_iter_reset * * Purpose: Reset a block iterator to it's initial state, freeing any * location context it currently has * * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * [email protected] * Apr 24 2006 * *------------------------------------------------------------------------- */ herr_t H5HF_man_iter_reset(H5HF_block_iter_t *biter) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iter_reset) /* * Check arguments. */ HDassert(biter); /* Free any location contexts that exist */ if(biter->curr) { H5HF_block_loc_t *curr_loc; /* Pointer to current block location */ H5HF_block_loc_t *next_loc; /* Pointer to next block location */ /* Free location contexts */ curr_loc = biter->curr; while(curr_loc) { /* Get pointer to next node */ next_loc = curr_loc->up; /* If this node is holding an indirect block, release the block */ if(curr_loc->context) if(H5HF_iblock_decr(curr_loc->context) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block") /* Free the current location context */ curr_loc = H5FL_FREE(H5HF_block_loc_t, curr_loc); /* Advance to next location */ curr_loc = next_loc; } /* end while */ /* Reset top location context */ biter->curr = NULL; } /* end if */ /* Reset block iterator flags */ biter->ready = FALSE; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HF_man_iter_reset() */
/*------------------------------------------------------------------------- * Function: h5trav_gettable * * Purpose: get the trav_table_t struct * * Return: 0 on success, * -1 on failure *------------------------------------------------------------------------- */ int h5trav_gettable(hid_t fid, trav_table_t *table) { trav_visitor_t table_visitor; /* Visitor structure for trav_table_t's */ int ret_value = SUCCEED; /* Init visitor structure */ table_visitor.visit_obj = trav_table_visit_obj; table_visitor.visit_lnk = trav_table_visit_lnk; table_visitor.udata = table; /* Traverse all objects in the file, visiting each object & link */ if(traverse(fid, "/", TRUE, TRUE, &table_visitor, H5O_INFO_BASIC) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed"); done: return ret_value; }
/*------------------------------------------------------------------------- * Function: H5Tget_sign * * Purpose: Retrieves the sign type for an integer type. * * Return: Success: The sign type. * * Failure: H5T_SGN_ERROR (Negative) * * Programmer: Robb Matzke * Wednesday, January 7, 1998 * * Modifications: * Robb Matzke, 22 Dec 1998 * Also works with derived datatypes. *------------------------------------------------------------------------- */ H5T_sign_t H5Tget_sign(hid_t type_id) { H5T_t *dt = NULL; H5T_sign_t ret_value; FUNC_ENTER_API(H5T_SGN_ERROR) H5TRACE1("Ts", "i", type_id); /* Check args */ if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_SGN_ERROR, "not an integer datatype") ret_value = H5T_get_sign(dt); done: FUNC_LEAVE_API(ret_value) }
/*-------------------------------------------------------------------------- NAME H5D_layout_version_test PURPOSE Determine the storage layout version for a dataset's layout information USAGE herr_t H5D_layout_version_test(did, version) hid_t did; IN: Dataset to query unsigned *version; OUT: Pointer to location to place version info RETURNS Non-negative on success, negative on failure DESCRIPTION Checks the version of the storage layout information for a dataset. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5D_layout_version_test(hid_t did, unsigned *version) { H5D_t *dset; /* Pointer to dataset to query */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI(H5D_layout_version_test, FAIL); /* Check args */ if (NULL==(dset=H5I_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(version) *version=dset->shared->layout.version; done: FUNC_LEAVE_NOAPI(ret_value); } /* H5D_layout_version_test() */
/*------------------------------------------------------------------------- * Function: named_datatype_free * * Purpose: Frees the stack of named datatypes. *------------------------------------------------------------------------- */ int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) { named_dt_t *dt = *named_dt_head_p; int ret_value = -1; while (dt) { /* Pop the datatype off the stack and free it */ if (H5Tclose(dt->id_out) < 0 && !ignore_err) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); dt = dt->next; HDfree(*named_dt_head_p); *named_dt_head_p = dt; } /* end while */ ret_value = 0; done: return (ret_value); } /* end named_datatype_free */
/*-------------------------------------------------------------------------- NAME H5O_attr_copy PURPOSE Copies a message from MESG to DEST, allocating DEST if necessary. USAGE void *H5O_attr_copy(mesg, dest) const void *mesg; IN: Pointer to the source attribute struct const void *dest; IN: Pointer to the destination attribute struct RETURNS Pointer to DEST on success, NULL on failure DESCRIPTION This function copies a native (memory) attribute message, allocating the destination structure if necessary. --------------------------------------------------------------------------*/ static void * H5O_attr_copy(const void *_src, void *_dst, unsigned update_flags) { const H5A_t *src = (const H5A_t *) _src; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_attr_copy); /* check args */ assert(src); /* copy */ if (NULL == (ret_value = H5A_copy(_dst,src,update_flags))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "can't copy attribute"); done: FUNC_LEAVE_NOAPI(ret_value); }
/*------------------------------------------------------------------------- * Function: H5I_nmembers * * Purpose: Returns the number of members in a group. * * Return: Success: Number of members; zero if the group is empty * or has been deleted. * * Failure: Negative * * Programmer: Robb Matzke * Wednesday, March 24, 1999 * * Modifications: * *------------------------------------------------------------------------- */ int H5I_nmembers(H5I_type_t grp) { H5I_id_group_t *grp_ptr = NULL; int ret_value; FUNC_ENTER_NOAPI(H5I_nmembers, FAIL); if (grp<=H5I_BADID || grp>=H5I_NGROUPS) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); if (NULL==(grp_ptr=H5I_id_group_list_g[grp]) || grp_ptr->count<=0) HGOTO_DONE(0); /* Set return value */ H5_ASSIGN_OVERFLOW(ret_value, grp_ptr->ids, unsigned, int); done: FUNC_LEAVE_NOAPI(ret_value); }
/*------------------------------------------------------------------------- * Function: H5O_layout_free * * Purpose: Free's the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Saturday, March 11, 2000 * *------------------------------------------------------------------------- */ static herr_t H5O_layout_free(void *_mesg) { H5O_layout_t *mesg = (H5O_layout_t *) _mesg; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_layout_free) HDassert(mesg); /* Free resources within the message */ if(H5O_layout_reset(mesg) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free message resources") mesg = H5FL_FREE(H5O_layout_t, mesg); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_layout_free() */
/*------------------------------------------------------------------------- * Function: H5MF_reserve * * Purpose: Sets aside file space that has not yet been allocated, but will * be (or might be in the worst case). This number is used to * ensure that there is room in the file when it is flushed to disk. * * Nothing changes (and no error is generated) if the file is opened * as read-only. * * Return: Success: 0 * * Failure: negative * * Programmer: James Laird * Nat Furrer * Thursday, May 27, 2004 * * Modifications: *------------------------------------------------------------------------- */ herr_t H5MF_reserve(H5F_t *f, hsize_t size) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5MF_reserve, FAIL); /* Check arguments */ assert(f); /* Check that there is room in the file to reserve this space */ if( H5MF_alloc_overflow( f, size ) ) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "not enough address space in file"); f->shared->lf->reserved_alloc += size; done: FUNC_LEAVE_NOAPI(ret_value); }
/*------------------------------------------------------------------------- * Function: H5O_efl_copy * * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if * necessary. * * Return: Success: Ptr to _DEST * * Failure: NULL * * Programmer: Robb Matzke * Tuesday, November 25, 1997 * *------------------------------------------------------------------------- */ static void * H5O_efl_copy(const void *_mesg, void *_dest) { const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; H5O_efl_t *dest = (H5O_efl_t *) _dest; size_t u; /* Local index variable */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_efl_copy) /* check args */ HDassert(mesg); if(!dest) { if(NULL == (dest = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message") if(NULL == (dest->slot = (H5O_efl_entry_t *)H5MM_calloc(mesg->nalloc * sizeof(H5O_efl_entry_t)))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slots") } /* end if */ else if(dest->nalloc < mesg->nalloc) {
/*------------------------------------------------------------------------- * Function: H5FS_close * * Purpose: Destroy & deallocate free list structure, serializing sections * in the bins * * Return: Success: non-negative * * Failure: negative * * Programmer: Quincey Koziol * Tuesday, March 7, 2006 * *------------------------------------------------------------------------- */ herr_t H5FS_close(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check arguments. */ HDassert(f); HDassert(fspace); #ifdef H5FS_DEBUG HDfprintf(stderr, "%s: Entering, fspace = %p, fspace->addr = %a, fspace->sinfo = %p\n", FUNC, fspace, fspace->addr, fspace->sinfo); #endif /* H5FS_DEBUG */ /* Check if section info is valid */ /* (i.e. the header "owns" the section info and it's not in the cache) */ if(fspace->sinfo) { #ifdef H5FS_DEBUG HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu, fspace->serial_sect_count = %Hu, fspace->sect_addr = %a, fspace->rc = %u\n", FUNC, fspace->tot_sect_count, fspace->serial_sect_count, fspace->sect_addr, fspace->rc); HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, fspace->alloc_sect_size, fspace->sect_size); #endif /* H5FS_DEBUG */ /* If there are sections to serialize, update them */ /* (if the free space manager is persistant) */ if(fspace->serial_sect_count > 0 && H5F_addr_defined(fspace->addr)) { #ifdef H5FS_DEBUG HDfprintf(stderr, "%s: Real sections to store in file\n", FUNC); #endif /* H5FS_DEBUG */ if(fspace->sinfo->dirty) { /* Check if the section info is "floating" */ if(!H5F_addr_defined(fspace->sect_addr)) { /* Sanity check */ HDassert(fspace->sect_size > 0); /* Allocate space for the section info in file */ if(HADDR_UNDEF == (fspace->sect_addr = H5MF_alloc(f, H5FD_MEM_FSPACE_SINFO, dxpl_id, fspace->sect_size))) HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, FAIL, "file allocation failed for free space sections") fspace->alloc_sect_size = (size_t)fspace->sect_size; /* Mark free space header as dirty */ if(H5AC_mark_entry_dirty(fspace) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty") } /* end if */ } /* end if */
/*------------------------------------------------------------------------- * Function: h5trav_visit * * Purpose: Generic traversal routine for visiting objects and links * * Return: 0 on success, * -1 on failure *------------------------------------------------------------------------- */ int h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start, hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, void *udata, unsigned fields) { trav_visitor_t visitor; /* Visitor structure for objects */ int ret_value = SUCCEED; /* Init visitor structure */ visitor.visit_obj = visit_obj; visitor.visit_lnk = visit_lnk; visitor.udata = udata; /* Traverse all objects in the file, visiting each object & link */ if(traverse(fid, grp_name, visit_start, recurse, &visitor, fields) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed"); done: return ret_value; }
/*-------------------------------------------------------------------------- NAME H5D_layout_contig_size_test PURPOSE Determine the size of a contiguous layout for a dataset's layout information USAGE herr_t H5D_layout_contig_size_test(did, size) hid_t did; IN: Dataset to query hsize_t *size; OUT: Pointer to location to place size info RETURNS Non-negative on success, negative on failure DESCRIPTION Checks the size of a contiguous dataset's storage. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t H5D_layout_contig_size_test(hid_t did, hsize_t *size) { H5D_t *dset; /* Pointer to dataset to query */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_NOAPI(H5D_layout_contig_size_test, FAIL); /* Check args */ if (NULL==(dset=H5I_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(size) { assert(dset->shared->layout.type==H5D_CONTIGUOUS); *size=dset->shared->layout.u.contig.size; } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value); } /* H5D_layout_contig_size_test() */
/*-------------------------------------------------------------------------- NAME HCIcszip_init -- Initialize a SZIP compressed data element. USAGE int32 HCIcszip_init(access_rec) accrec_t *access_rec; IN: the access record of the data element RETURNS Returns SUCCEED or FAIL DESCRIPTION Common code called by HCIcszip_staccess and HCIcszip_seek GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ PRIVATE int32 HCIcszip_init(accrec_t * access_rec) { CONSTR(FUNC, "HCIcszip_init"); compinfo_t *info; /* special element information */ comp_coder_szip_info_t *szip_info; /* ptr to SZIP info */ intn ret_value = SUCCEED; #ifdef H4_HAVE_LIBSZ /* Sanity check to make certain that we haven't drifted out of date with * the mask options from the SZIP ricehdf.h header */ assert(H4_SZ_ALLOW_K13_OPTION_MASK==SZ_ALLOW_K13_OPTION_MASK); assert(H4_SZ_CHIP_OPTION_MASK==SZ_CHIP_OPTION_MASK); assert(H4_SZ_EC_OPTION_MASK==SZ_EC_OPTION_MASK); assert(H4_SZ_LSB_OPTION_MASK==SZ_LSB_OPTION_MASK); assert(H4_SZ_MSB_OPTION_MASK==SZ_MSB_OPTION_MASK); assert(H4_SZ_NN_OPTION_MASK==SZ_NN_OPTION_MASK); assert(H4_SZ_RAW_OPTION_MASK==SZ_RAW_OPTION_MASK); #endif info = (compinfo_t *) access_rec->special_info; if (Hseek(info->aid, 0, DF_START) == FAIL) /* seek to beginning of element */ HGOTO_ERROR(DFE_SEEKERROR, FAIL); szip_info = &(info->cinfo.coder_info.szip_info); /* Initialize SZIP state information */ szip_info->szip_state = SZIP_INIT; /* start in initial state */ if (szip_info->buffer_size != 0) { szip_info->buffer_size = 0; /* offset into the file */ if (szip_info->buffer != NULL) { HDfree(szip_info->buffer); szip_info->buffer = NULL; } } szip_info->offset = 0; /* offset into the file */ szip_info->szip_dirty=SZIP_CLEAN; done: return(ret_value); } /* end HCIcszip_init() */
/*------------------------------------------------------------------------- * Function: H5MF_can_extend * * Purpose: Check if a block in the file can be extended. * * This is a simple check currently, which only checks for the * block being at the end of the file. A more sophisticated check * would also use the free space list to see if there is a block * appropriately placed to accomodate the space requested. * * Return: Success: TRUE(1)/FALSE(0) * * Failure: FAIL * * Programmer: Quincey Koziol * Friday, June 11, 2004 * * Modifications: * *------------------------------------------------------------------------- */ htri_t H5MF_can_extend(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hsize_t extra_requested) { htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5MF_can_extend, FAIL); /* Convert old relative address to absolute address */ addr += H5F_BASE_ADDR(f); /* Pass the request down to the virtual file layer */ if((ret_value=H5FD_can_extend(f->shared->lf, type, addr, size, extra_requested))<0) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate new file memory"); /* Make sure there is enough addressable space to satisfy the request */ if (ret_value == TRUE) ret_value = !H5MF_alloc_overflow(f, extra_requested); done: FUNC_LEAVE_NOAPI(ret_value); } /* end H5MF_can_extend() */
/*------------------------------------------------------------------------- * Function: H5F_cwfs_add * * Purpose: Add a global heap collection to the CWFS for a file. * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * Tuesday, July 19, 2011 * *------------------------------------------------------------------------- */ herr_t H5F_cwfs_add(H5F_t *f, H5HG_heap_t *heap) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(f); HDassert(f->shared); HDassert(heap); /* * Add the new heap to the CWFS list, removing some other entry if * necessary to make room. We remove the right-most entry that has less * free space than this heap. */ if(NULL == f->shared->cwfs) { if(NULL == (f->shared->cwfs = (H5HG_heap_t **)H5MM_malloc(H5F_NCWFS * sizeof(H5HG_heap_t *)))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't allocate CWFS for file") f->shared->cwfs[0] = heap; f->shared->ncwfs = 1; } else if(H5F_NCWFS == f->shared->ncwfs) { int i; /* Local index variable */ for(i = H5F_NCWFS - 1; i >= 0; --i) if(H5HG_FREE_SIZE(f->shared->cwfs[i]) < H5HG_FREE_SIZE(heap)) { HDmemmove(f->shared->cwfs + 1, f->shared->cwfs, (size_t)i * sizeof(H5HG_heap_t *)); f->shared->cwfs[0] = heap; break; } /* end if */ } else { HDmemmove(f->shared->cwfs + 1, f->shared->cwfs, f->shared->ncwfs * sizeof(H5HG_heap_t *)); f->shared->cwfs[0] = heap; f->shared->ncwfs += 1; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_cwfs_add() */
/*------------------------------------------------------------------------- * Function: H5D__scatter_file * * Purpose: Scatters dataset elements from the type conversion buffer BUF * to the file F where the data points are arranged according to * the file dataspace FILE_SPACE and stored according to * LAYOUT and EFL. Each element is ELMT_SIZE bytes. * The caller is requesting that NELMTS elements are copied. * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, June 20, 2002 * *------------------------------------------------------------------------- */ static herr_t H5D__scatter_file(const H5D_io_info_t *_io_info, const H5S_t *space, H5S_sel_iter_t *iter, size_t nelmts, const void *_buf) { H5D_io_info_t tmp_io_info; /* Temporary I/O info object */ hsize_t _off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */ hsize_t *off = NULL; /* Pointer to sequence offsets */ hsize_t mem_off; /* Offset in memory */ size_t mem_curr_seq; /* "Current sequence" in memory */ size_t dset_curr_seq; /* "Current sequence" in dataset */ size_t _len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */ size_t *len = NULL; /* Array to store sequence lengths */ size_t orig_mem_len, mem_len; /* Length of sequence in memory */ size_t nseq; /* Number of sequences generated */ size_t nelem; /* Number of elements used in sequences */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Check args */ HDassert(_io_info); HDassert(space); HDassert(iter); HDassert(nelmts > 0); HDassert(_buf); /* Set up temporary I/O info object */ HDmemcpy(&tmp_io_info, _io_info, sizeof(*_io_info)); tmp_io_info.op_type = H5D_IO_OP_WRITE; tmp_io_info.u.wbuf = _buf; /* Allocate the vector I/O arrays */ if(tmp_io_info.dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE) { if(NULL == (len = H5FL_SEQ_MALLOC(size_t, tmp_io_info.dxpl_cache->vec_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array") if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, tmp_io_info.dxpl_cache->vec_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array") } /* end if */ else {