* Update API tracing for new H5VL_request_status_t typedef
* Finish converting internal event set operations to use list iterator callbacks, instead of directly accessing the list structure
* Add H5VL_REQUEST_GET_ERR_STACK operation to request subclass, for retrieving a copy of the error stack for a failed asynchronous operation
* Remove 'canceled' event status from Java constants
* Be safer about releasing resources when inserting a newly opened/created object or file into an event set
* Remove H5EStest, add H5ES_WAIT_NONE for 0 timeout, and revise parameters to H5ESwait, to make it more "aggregate".
* Remove H5ES_STATUS_CANCELED from Java wrappers also
* Apply patch for dynamically registering optional VOL operations
* (a) Add async APIs for H5O module as listed in jira issue ID-283.
(b) Remove verification of name parameter in async related routines for H55A and H5L modules
because it is checked in H5VL_setup* routine.
(c) Modify h5dump expected output due to the async changes.
* Corrections based on PR feedback.
* Further changes to make based on PR feedback.
* Remove H5Dwait & H5Fwait (moved to the async connector). Added H5atclose
routine. Updated 'optional op' operations.
* Fix missed merge marker, and reformatted line
* Update API tracing infrastructure for H5atclose callback
* Clean up some warnings
* Normalize against develop branch
* Correct level of indirection
* Add doxygen info for H5is_library_terminating and regression tests for it and H5atclose
* Relocate prototype (and doxygen info) for H5Aclose
* Align w/changes on develop
* Move group package initialization code to H5Gint.c, and update tracing macros
* Change non-static function declarations to be static
* Correct GCC diagnostic macro
* Ensure that H5TSpublic.h header gets installed (#129)
* Finish moving API routines that invoke VOL framework to main source files.
* Fix position of H5Fmount and H5Funmount
* Add 'wrapper' versions of async calls, to allow language wrappers and layers on top of HDF5 to pass in their application information.
* Add wrappers for dynamically registered optional operations
* Fix typo
* Update doxygen comment for H5atclose with additional detail.
* Add H5VL\*_vararg versions of H5VL routines that use va_list parameters
* Implement and test H5S_BLOCK
* Switch H5Aexists\*_async and H5Lexists\*_async to use flag to return status, instead of return value. Make the corresponding changes through most of the v1 and v2 B-tree code. Clean up warnings in H5public.h and cmpd_dtransform.c.
* Add H5Iregister_future routine and tests.
* Correct return value for H5Lexists_async
* Add H5_DLL macro to public H5ES API routines
* Update supported -> flags parameter for introspect_query callback
* Remove my email address. Update passthrough VOL connector ID.
* Fix comment for post_open_api_common
* Remove unused non-blocking VOL connector
* Minor cleanup in async branch in preparation for merge to develop
* Update CMake and the Autotools to use the new pass-through VOL ID
* Finish another iteration on public H5ES routines, along with running the code reformatter
* Another round of reformatting
* Fix for SWMR daily test failures (#160)
The H5I_register_using_existing_id() call did not initialize the future
ID callbacks, causing the library to segfault when it tried to
resolve those function pointers.
* Added selective async APIs (#150)
* Added selective async APIs
Description:
Added the following APIs:
H5Ropen_attr_async
H5Ropen_object_async
H5Ropen_region_async
H5Mcreate_async
H5Mopen_async
H5Mput_async
H5Mget_async
H5Mclose_async
H5Tcommit_async
H5Topen_async
H5Tcopy_async
H5Tclose_async
- Updated an expected output file to include a new internal function
in the error stack for the failure case.
* Updated async APIs per reviews, including removing async version of
H5Tcopy.
* Removed statements that were added by mistake in the previous commit.
* Fix compile issues in H5M and warnings elsewhere
* Reformat code
* Brings VOL_LIST changes from develop. (#163)
* Remove H5Dwait and H5Fwait calls, which were incorrectly brought back in
* Tiny cleanup of H5Lcreate_hard_async
* Run source formatter
* Allow for canceled operation in wait_cb
* Attempt to fix switch on string value
* Re-run source formatter
* Add H5S_BLOCK testfile to CMake clean target
* Add H5Pset_vol_async API routine and 'get_cap_flags' VOL introspection callback
* Clean up warnings
* Add H5P(set\|get)_vol_implicit_async API routines to allow \/ disallow implicit asynchronous operations (default is disallowed)
* Run formatting script
* Remove H5VL_REQUEST_WAIT\*
* Warning cleanup
* Eliminate strdup()s on statically allocated strings
* Warning cleanup
* Split H5VLrestore_lib_state into H5VLstart_lib_state and H5VLrestore_lib_state, and rename H5VLreset_lib_state to H5VLfinish_lib_state.
* Duplicate strings when building err_info to return to applicatin
* Move connector author routines into seperate header files, all included in the new hdf5dev.h header
* Run bin/trace to add TRACE macros
* Allow H5ES_NONE as a valid, but no-op, parameter to all H5ES API routines that accept an event set ID
* Clean up formatting
* Remove H5Pset/get_vol_implicit_async
* Clean up warning
* Remove H5Pget_vol_async and replace with more generic H5Pget_vol_cap_flags
* Clean up warnings
* Add H5ESfree_err_info convenience routine
* Fix typo
* Correct matching for cached VOL plugins
* Add developer header file
* Update for C99 compatibility
* Add missing trace macro
* Stop clang-format from messing with the trace macros. Don't set up VOL wrappers for 'infrastructure' objects like requests and blobs
* Fix warning about formatting a directory
* Clean up formatting for H5E_BEGIN_TRY / H5E_END_TRY
* Reduce scope of H5ES__close
* Enable CMake checks for various types on MacOS
* Clean up properly when H5CX_retrieve_state() fails. Also clean up many compiler warnings.
* Committing clang-format changes
* Merge from develop
* Fix mis-placed assert
* Remove commented-out code
* Re-add macro for unsetenv on Windows (I think it accidentally was merged out)
* Strengthen sanity check from error report to assertion
* Committing clang-format changes
* Add units to the comments for a few fields
* Switch 'get execution time' operation for async request tokens to be an optional operation and query if connector supports operation before retrieving it.
* Committing clang-format changes
* Remove H5ESget_time_estimate
* Committing clang-format changes
* Create developer header for datatype routines and move type conversion register/unregister routines there.
* Simplify internal H5VL_setup_name_args and H5VL_setup_idx_args routines
* Add H5VLlink_optional_op, allowing dynamicly registered optional operations for the link VOL subclass, also added H5VL_loc_params argument to the link 'optional' callback to allow them to work correctly.
* Run bin/format_source on current code
* Add H5VLobject_optional_op, allowing dynamicly registered optional operations for the object VOL subclass, also added H5VL_loc_params argument to the object 'optional' callback to allow them to work correctly.
* Run bin/format_source on current code
* Committing clang-format changes
* Revert "Switch 'get execution time' operation for async request tokens to be an optional operation and query if connector supports operation before retrieving it."
This reverts commit 5ac92014da.
* Committing clang-format changes
* Convert attribute 'get' operation to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs.
* Update tracing macros
* Convert attribute 'specific' operation to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs.
* Convert dataset 'get' and 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also, minor tweaks to attribute 'get' and 'specific' operation parameters.
* Convert datatype 'get' and 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also, minor tweaks to H5O_refresh_metadata arguments.
* Reduce warnings
* Reduce warnings
* Track change to datatype 'get' callback
* Fix bug with file pointer getting invalidated when object closed
* Reformat source
* Convert file and group VOL classes 'get' and 'specific' operations to use
struct-of-tagged-union pattern for VOL callback arguments, instead of using
varargs. Also small cleanup to the attribute get name operation. Also moved
'mount' and 'unmount' operations to be group specific operations, instead of
file specific, to better align with their behavior (mounted files are on
groups, so a group is what is operated on).
* Remove remainder of merge conflict marking
* Convert link VOL class 'create' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs.
* Remove some unused local variables
* Convert link VOL class 'get' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also refactor 'get name by idx' routines to return actual length of name with a parameter instead of the return value, and move some callback context structs for the link interface from the private header file into the source code module, to reduce their visibility scope.
* Update tracing macros
* Convert link VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs.
* Convert object VOL class 'get' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs.
* Convert object VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also refactor H5G_loc_exists, et al, to return 'exists' flag in a parameter and errors with the function return value, instead of overloading both into the return value. And, corrected logic error in test/links.c around non-existant objects in a file.
* Convert request VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs.
* Convert blob VOL class 'specific' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Also removes the H5VL_BLOB_GETSIZE operation, as it's unused in the library and the blob ID size for a container is now returned with H5VL_FILE_GET_CONT_INFO.
* Add 'const' to several parameters that are only queried.
* Convert all VOL classes' 'optional' operations to use struct-of-tagged-union pattern for VOL callback arguments, instead of using varargs. Convert several 'get' routines to return the length of an array in a parameter instead of combining it into the return value. Move several routines to be in less public namespace. Correct direct_chunk test to verify that parameters aren't modified on error.
* Switch get/specific/optional VOL callback argument structures to be 'async-friendly'. Also other minor cleanups and bug-fixes.
* Add H5Pset_dataset_io_hyperslab_selection / H5S_PLIST feature, to allow skipping H5Dget_space + H5Sselect_hyperslab for async operation
* Add dynamic optional operations for request objects
* Update dynamic operation test for optional request operations
* Update a comment for an operation argument
* Run trace and format_source scripts
* Committing clang-format changes
* Committing clang-format changes
Co-authored-by: vchoi <vchoi@jelly.ad.hdfgroup.org>
Co-authored-by: vchoi-hdfgroup <55293060+vchoi-hdfgroup@users.noreply.github.com>
Co-authored-by: jhendersonHDF <jhenderson@hdfgroup.org>
Co-authored-by: Dana Robinson <derobins@hdfgroup.org>
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1209 lines
40 KiB
C
1209 lines
40 KiB
C
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
* Copyright by The HDF Group. *
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
* All rights reserved. *
|
|
* *
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
* the COPYING file, which can be found at the root of the source code *
|
|
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
|
* If you do not have access to either file, you may request a copy from *
|
|
* help@hdfgroup.org. *
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
/*
|
|
* Module Info: This module contains the functionality for variable-length
|
|
* datatypes in the H5T interface.
|
|
*/
|
|
|
|
/****************/
|
|
/* Module Setup */
|
|
/****************/
|
|
|
|
#include "H5Tmodule.h" /* This source code file is part of the H5T module */
|
|
#define H5F_FRIEND /*suppress error about including H5Fpkg */
|
|
|
|
/***********/
|
|
/* Headers */
|
|
/***********/
|
|
#include "H5private.h" /* Generic Functions */
|
|
#include "H5CXprivate.h" /* API Contexts */
|
|
#include "H5Eprivate.h" /* Error handling */
|
|
#include "H5Fpkg.h" /* File */
|
|
#include "H5Iprivate.h" /* IDs */
|
|
#include "H5MMprivate.h" /* Memory management */
|
|
#include "H5Tpkg.h" /* Datatypes */
|
|
#include "H5VLprivate.h" /* Virtual Object Layer */
|
|
|
|
/****************/
|
|
/* Local Macros */
|
|
/****************/
|
|
|
|
/******************/
|
|
/* Local Typedefs */
|
|
/******************/
|
|
|
|
/********************/
|
|
/* Package Typedefs */
|
|
/********************/
|
|
|
|
/********************/
|
|
/* Local Prototypes */
|
|
/********************/
|
|
|
|
/* Memory-based VL sequence callbacks */
|
|
static herr_t H5T__vlen_mem_seq_getlen(H5VL_object_t *file, const void *_vl, size_t *len);
|
|
static void * H5T__vlen_mem_seq_getptr(void *_vl);
|
|
static herr_t H5T__vlen_mem_seq_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull);
|
|
static herr_t H5T__vlen_mem_seq_setnull(H5VL_object_t *file, void *_vl, void *_bg);
|
|
static herr_t H5T__vlen_mem_seq_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len);
|
|
static herr_t H5T__vlen_mem_seq_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info,
|
|
void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size);
|
|
|
|
/* Memory-based VL string callbacks */
|
|
static herr_t H5T__vlen_mem_str_getlen(H5VL_object_t *file, const void *_vl, size_t *len);
|
|
static void * H5T__vlen_mem_str_getptr(void *_vl);
|
|
static herr_t H5T__vlen_mem_str_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull);
|
|
static herr_t H5T__vlen_mem_str_setnull(H5VL_object_t *file, void *_vl, void *_bg);
|
|
static herr_t H5T__vlen_mem_str_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len);
|
|
static herr_t H5T__vlen_mem_str_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info,
|
|
void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size);
|
|
|
|
/* Disk-based VL sequence (and string) callbacks */
|
|
static herr_t H5T__vlen_disk_getlen(H5VL_object_t *file, const void *_vl, size_t *len);
|
|
static herr_t H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull);
|
|
static herr_t H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *_bg);
|
|
static herr_t H5T__vlen_disk_read(H5VL_object_t *file, void *_vl, void *_buf, size_t len);
|
|
static herr_t H5T__vlen_disk_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl,
|
|
void *_buf, void *_bg, size_t seq_len, size_t base_size);
|
|
static herr_t H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl);
|
|
|
|
/*********************/
|
|
/* Public Variables */
|
|
/*********************/
|
|
|
|
/*********************/
|
|
/* Package Variables */
|
|
/*********************/
|
|
|
|
/*****************************/
|
|
/* Library Private Variables */
|
|
/*****************************/
|
|
|
|
/*******************/
|
|
/* Local Variables */
|
|
/*******************/
|
|
|
|
/* Class for VL sequences in memory */
|
|
static const H5T_vlen_class_t H5T_vlen_mem_seq_g = {
|
|
H5T__vlen_mem_seq_getlen, /* 'getlen' */
|
|
H5T__vlen_mem_seq_getptr, /* 'getptr' */
|
|
H5T__vlen_mem_seq_isnull, /* 'isnull' */
|
|
H5T__vlen_mem_seq_setnull, /* 'setnull' */
|
|
H5T__vlen_mem_seq_read, /* 'read' */
|
|
H5T__vlen_mem_seq_write, /* 'write' */
|
|
NULL /* 'delete' */
|
|
};
|
|
|
|
/* Class for VL strings in memory */
|
|
static const H5T_vlen_class_t H5T_vlen_mem_str_g = {
|
|
H5T__vlen_mem_str_getlen, /* 'getlen' */
|
|
H5T__vlen_mem_str_getptr, /* 'getptr' */
|
|
H5T__vlen_mem_str_isnull, /* 'isnull' */
|
|
H5T__vlen_mem_str_setnull, /* 'setnull' */
|
|
H5T__vlen_mem_str_read, /* 'read' */
|
|
H5T__vlen_mem_str_write, /* 'write' */
|
|
NULL /* 'delete' */
|
|
};
|
|
|
|
/* Class for both VL strings and sequences in file */
|
|
static const H5T_vlen_class_t H5T_vlen_disk_g = {
|
|
H5T__vlen_disk_getlen, /* 'getlen' */
|
|
NULL, /* 'getptr' */
|
|
H5T__vlen_disk_isnull, /* 'isnull' */
|
|
H5T__vlen_disk_setnull, /* 'setnull' */
|
|
H5T__vlen_disk_read, /* 'read' */
|
|
H5T__vlen_disk_write, /* 'write' */
|
|
H5T__vlen_disk_delete /* 'delete' */
|
|
};
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5Tvlen_create
|
|
*
|
|
* Purpose: Create a new variable-length datatype based on the specified
|
|
* BASE_TYPE.
|
|
*
|
|
* Return: Success: ID of new VL datatype
|
|
*
|
|
* Failure: Negative
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Thursday, May 20, 1999
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
hid_t
|
|
H5Tvlen_create(hid_t base_id)
|
|
{
|
|
H5T_t *base = NULL; /*base datatype */
|
|
H5T_t *dt = NULL; /*new datatype */
|
|
hid_t ret_value; /*return value */
|
|
|
|
FUNC_ENTER_API(FAIL)
|
|
H5TRACE1("i", "i", base_id);
|
|
|
|
/* Check args */
|
|
if (NULL == (base = (H5T_t *)H5I_object_verify(base_id, H5I_DATATYPE)))
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype")
|
|
|
|
/* Create up VL datatype */
|
|
if ((dt = H5T__vlen_create(base)) == NULL)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location")
|
|
|
|
/* Register the type */
|
|
if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype")
|
|
|
|
done:
|
|
FUNC_LEAVE_API(ret_value)
|
|
} /* end H5Tvlen_create() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_create
|
|
*
|
|
* Purpose: Create a new variable-length datatype based on the specified
|
|
* BASE_TYPE.
|
|
*
|
|
* Return: Success: new VL datatype
|
|
*
|
|
* Failure: NULL
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Tuesday, November 20, 2001
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
H5T_t *
|
|
H5T__vlen_create(const H5T_t *base)
|
|
{
|
|
H5T_t *dt = NULL; /* New VL datatype */
|
|
H5T_t *ret_value = NULL; /* Return value */
|
|
|
|
FUNC_ENTER_PACKAGE
|
|
|
|
/* Check args */
|
|
HDassert(base);
|
|
|
|
/* Build new type */
|
|
if (NULL == (dt = H5T__alloc()))
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "memory allocation failed")
|
|
dt->shared->type = H5T_VLEN;
|
|
|
|
/*
|
|
* Force conversions (i.e. memory to memory conversions should duplicate
|
|
* data, not point to the same VL sequences)
|
|
*/
|
|
dt->shared->force_conv = TRUE;
|
|
if (NULL == (dt->shared->parent = H5T_copy(base, H5T_COPY_ALL)))
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy base datatype")
|
|
|
|
/* Inherit encoding version from base type */
|
|
dt->shared->version = base->shared->version;
|
|
|
|
/* This is a sequence, not a string */
|
|
dt->shared->u.vlen.type = H5T_VLEN_SEQUENCE;
|
|
|
|
/* Set up VL information */
|
|
if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location")
|
|
|
|
/* Set return value */
|
|
ret_value = dt;
|
|
|
|
done:
|
|
if (!ret_value)
|
|
if (dt && H5T_close_real(dt) < 0)
|
|
HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "unable to release datatype info")
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
} /* end H5T__vlen_create() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_set_loc
|
|
*
|
|
* Purpose: Sets the location of a VL datatype to be either on disk or in memory
|
|
*
|
|
* Return:
|
|
* One of two values on success:
|
|
* TRUE - If the location of any vlen types changed
|
|
* FALSE - If the location of any vlen types is the same
|
|
* <0 is returned on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Friday, June 4, 1999
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
htri_t
|
|
H5T__vlen_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc)
|
|
{
|
|
htri_t ret_value = FALSE; /* Indicate success, but no location change */
|
|
|
|
FUNC_ENTER_PACKAGE
|
|
|
|
/* check parameters */
|
|
HDassert(dt);
|
|
HDassert(loc >= H5T_LOC_BADLOC && loc < H5T_LOC_MAXLOC);
|
|
|
|
/* Only change the location if it's different */
|
|
if (loc != dt->shared->u.vlen.loc || file != dt->shared->u.vlen.file) {
|
|
switch (loc) {
|
|
case H5T_LOC_MEMORY: /* Memory based VL datatype */
|
|
HDassert(NULL == file);
|
|
|
|
/* Mark this type as being stored in memory */
|
|
dt->shared->u.vlen.loc = H5T_LOC_MEMORY;
|
|
|
|
if (dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) {
|
|
/* Size in memory, disk size is different */
|
|
dt->shared->size = sizeof(hvl_t);
|
|
|
|
/* Set up the function pointers to access the VL sequence in memory */
|
|
dt->shared->u.vlen.cls = &H5T_vlen_mem_seq_g;
|
|
} /* end if */
|
|
else if (dt->shared->u.vlen.type == H5T_VLEN_STRING) {
|
|
/* Size in memory, disk size is different */
|
|
dt->shared->size = sizeof(char *);
|
|
|
|
/* Set up the function pointers to access the VL string in memory */
|
|
dt->shared->u.vlen.cls = &H5T_vlen_mem_str_g;
|
|
} /* end else-if */
|
|
else
|
|
HDassert(0 && "Invalid VL type");
|
|
|
|
/* Release owned file */
|
|
if (dt->shared->owned_vol_obj) {
|
|
if (H5VL_free_object(dt->shared->owned_vol_obj) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close owned VOL object")
|
|
dt->shared->owned_vol_obj = NULL;
|
|
} /* end if */
|
|
|
|
/* Reset file pointer (since this VL is in memory) */
|
|
dt->shared->u.vlen.file = NULL;
|
|
break;
|
|
|
|
/* Disk based VL datatype */
|
|
case H5T_LOC_DISK: {
|
|
H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0};
|
|
H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */
|
|
|
|
HDassert(file);
|
|
|
|
/* Mark this type as being stored on disk */
|
|
dt->shared->u.vlen.loc = H5T_LOC_DISK;
|
|
|
|
/* Set up VOL callback arguments */
|
|
vol_cb_args.op_type = H5VL_FILE_GET_CONT_INFO;
|
|
vol_cb_args.args.get_cont_info.info = &cont_info;
|
|
|
|
/* Get container info */
|
|
if (H5VL_file_get(file, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get container info")
|
|
|
|
/* The datatype size is equal to 4 bytes for the sequence length
|
|
* plus the size of a blob id */
|
|
dt->shared->size = 4 + cont_info.blob_id_size;
|
|
|
|
/* Set up the function pointers to access the VL information on disk */
|
|
/* VL sequences and VL strings are stored identically on disk, so use the same functions */
|
|
dt->shared->u.vlen.cls = &H5T_vlen_disk_g;
|
|
|
|
/* Set file ID (since this VL is on disk) */
|
|
dt->shared->u.vlen.file = file;
|
|
|
|
/* dt now owns a reference to file */
|
|
if (H5T_own_vol_obj(dt, file) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't give ownership of VOL object")
|
|
break;
|
|
}
|
|
|
|
case H5T_LOC_BADLOC:
|
|
/* Allow undefined location. In H5Odtype.c, H5O_dtype_decode sets undefined
|
|
* location for VL type and leaves it for the caller to decide.
|
|
*/
|
|
dt->shared->u.vlen.loc = H5T_LOC_BADLOC;
|
|
|
|
/* Reset the function pointers to access the VL information */
|
|
dt->shared->u.vlen.cls = NULL;
|
|
|
|
/* Reset file pointer */
|
|
dt->shared->u.vlen.file = NULL;
|
|
break;
|
|
|
|
case H5T_LOC_MAXLOC:
|
|
/* MAXLOC is invalid */
|
|
default:
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid VL datatype location")
|
|
} /* end switch */ /*lint !e788 All appropriate cases are covered */
|
|
|
|
/* Indicate that the location changed */
|
|
ret_value = TRUE;
|
|
} /* end if */
|
|
|
|
done:
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
} /* end H5T__vlen_set_loc() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_mem_seq_getlen
|
|
*
|
|
* Purpose: Retrieves the length of a memory based VL element.
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Wednesday, June 2, 1999
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_mem_seq_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_t *len)
|
|
{
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */
|
|
#else
|
|
hvl_t vl; /* User's hvl_t information */
|
|
#endif
|
|
|
|
FUNC_ENTER_STATIC_NOERR
|
|
|
|
/* Check parameter */
|
|
HDassert(_vl);
|
|
HDassert(len);
|
|
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
*len = vl->len;
|
|
#else
|
|
H5MM_memcpy(&vl, _vl, sizeof(hvl_t));
|
|
|
|
*len = vl.len;
|
|
#endif
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
|
} /* end H5T__vlen_mem_seq_getlen() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_mem_seq_getptr
|
|
*
|
|
* Purpose: Retrieves the pointer for a memory based VL element.
|
|
*
|
|
* Return: Non-NULL on success/NULL on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Saturday, June 12, 2004
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static void *
|
|
H5T__vlen_mem_seq_getptr(void *_vl)
|
|
{
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */
|
|
#else
|
|
hvl_t vl; /* User's hvl_t information */
|
|
#endif
|
|
|
|
FUNC_ENTER_STATIC_NOERR
|
|
|
|
/* check parameters, return result */
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
HDassert(vl);
|
|
|
|
FUNC_LEAVE_NOAPI(vl->p)
|
|
#else
|
|
HDassert(_vl);
|
|
H5MM_memcpy(&vl, _vl, sizeof(hvl_t));
|
|
|
|
FUNC_LEAVE_NOAPI(vl.p)
|
|
#endif
|
|
} /* end H5T__vlen_mem_seq_getptr() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_mem_seq_isnull
|
|
*
|
|
* Purpose: Checks if a memory sequence is the "null" sequence
|
|
*
|
|
* Return: Non-negative on success / Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Saturday, November 8, 2003
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_mem_seq_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hbool_t *isnull)
|
|
{
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */
|
|
#else
|
|
hvl_t vl; /* User's hvl_t information */
|
|
#endif
|
|
|
|
FUNC_ENTER_STATIC_NOERR
|
|
|
|
/* Check parameters */
|
|
HDassert(_vl);
|
|
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
*isnull = ((vl->len == 0 || vl->p == NULL) ? TRUE : FALSE);
|
|
#else
|
|
H5MM_memcpy(&vl, _vl, sizeof(hvl_t));
|
|
|
|
*isnull = ((vl.len == 0 || vl.p == NULL) ? TRUE : FALSE);
|
|
#endif
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
|
} /* end H5T__vlen_mem_seq_isnull() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_mem_seq_setnull
|
|
*
|
|
* Purpose: Sets a VL info object in memory to the "nil" value
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Saturday, November 8, 2003
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_mem_seq_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5_ATTR_UNUSED *_bg)
|
|
{
|
|
hvl_t vl; /* Temporary hvl_t to use during operation */
|
|
|
|
FUNC_ENTER_STATIC_NOERR
|
|
|
|
/* check parameters */
|
|
HDassert(_vl);
|
|
|
|
/* Set the "nil" hvl_t */
|
|
vl.len = 0;
|
|
vl.p = NULL;
|
|
|
|
/* Set pointer in user's buffer with memcpy, to avoid alignment issues */
|
|
H5MM_memcpy(_vl, &vl, sizeof(hvl_t));
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
|
} /* end H5T__vlen_mem_seq_setnull() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_mem_seq_read
|
|
*
|
|
* Purpose: "Reads" the memory based VL sequence into a buffer
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Wednesday, June 2, 1999
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_mem_seq_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, size_t len)
|
|
{
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */
|
|
#else
|
|
hvl_t vl; /* User's hvl_t information */
|
|
#endif
|
|
|
|
FUNC_ENTER_STATIC_NOERR
|
|
|
|
/* check parameters, copy data */
|
|
HDassert(buf);
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
HDassert(vl && vl->p);
|
|
|
|
H5MM_memcpy(buf, vl->p, len);
|
|
#else
|
|
HDassert(_vl);
|
|
H5MM_memcpy(&vl, _vl, sizeof(hvl_t));
|
|
HDassert(vl.p);
|
|
|
|
H5MM_memcpy(buf, vl.p, len);
|
|
#endif
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
|
} /* end H5T__vlen_mem_seq_read() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_mem_seq_write
|
|
*
|
|
* Purpose: "Writes" the memory based VL sequence from a buffer
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Wednesday, June 2, 1999
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_mem_seq_write(H5VL_object_t H5_ATTR_UNUSED *file, const H5T_vlen_alloc_info_t *vl_alloc_info,
|
|
void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size)
|
|
{
|
|
hvl_t vl; /* Temporary hvl_t to use during operation */
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
|
|
|
FUNC_ENTER_STATIC
|
|
|
|
/* check parameters */
|
|
HDassert(_vl);
|
|
HDassert(buf);
|
|
|
|
if (seq_len) {
|
|
size_t len = seq_len * base_size; /* Sequence size */
|
|
|
|
/* Use the user's memory allocation routine is one is defined */
|
|
if (vl_alloc_info->alloc_func != NULL) {
|
|
if (NULL == (vl.p = (vl_alloc_info->alloc_func)(len, vl_alloc_info->alloc_info)))
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL,
|
|
"application memory allocation routine failed for VL data")
|
|
} /* end if */
|
|
else /* Default to system malloc */
|
|
if (NULL == (vl.p = HDmalloc(len)))
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed for VL data")
|
|
|
|
/* Copy the data into the newly allocated buffer */
|
|
H5MM_memcpy(vl.p, buf, len);
|
|
} /* end if */
|
|
else
|
|
vl.p = NULL;
|
|
|
|
/* Set the sequence length */
|
|
vl.len = seq_len;
|
|
|
|
/* Set pointer in user's buffer with memcpy, to avoid alignment issues */
|
|
H5MM_memcpy(_vl, &vl, sizeof(hvl_t));
|
|
|
|
done:
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
} /* end H5T__vlen_mem_seq_write() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_mem_str_getlen
|
|
*
|
|
* Purpose: Retrieves the length of a memory based VL string.
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Wednesday, June 2, 1999
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_mem_str_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_t *len)
|
|
{
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
const char *s = *(const char *const *)_vl; /* Pointer to the user's string information */
|
|
#else
|
|
const char *s = NULL; /* Pointer to the user's string information */
|
|
#endif
|
|
|
|
FUNC_ENTER_STATIC_NOERR
|
|
|
|
/* check parameters */
|
|
HDassert(_vl);
|
|
|
|
#ifndef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
H5MM_memcpy(&s, _vl, sizeof(char *));
|
|
#endif
|
|
|
|
*len = HDstrlen(s);
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
|
} /* end H5T__vlen_mem_str_getlen() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_mem_str_getptr
|
|
*
|
|
* Purpose: Retrieves the pointer for a memory based VL string.
|
|
*
|
|
* Return: Non-NULL on success/NULL on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Saturday, June 12, 2004
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static void *
|
|
H5T__vlen_mem_str_getptr(void *_vl)
|
|
{
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
char *s = *(char **)_vl; /* Pointer to the user's string information */
|
|
#else
|
|
char * s = NULL; /* Pointer to the user's string information */
|
|
#endif
|
|
|
|
FUNC_ENTER_STATIC_NOERR
|
|
|
|
/* check parameters */
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
HDassert(s);
|
|
#else
|
|
HDassert(_vl);
|
|
H5MM_memcpy(&s, _vl, sizeof(char *));
|
|
#endif
|
|
|
|
FUNC_LEAVE_NOAPI(s)
|
|
} /* end H5T__vlen_mem_str_getptr() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_mem_str_isnull
|
|
*
|
|
* Purpose: Checks if a memory string is a NULL pointer
|
|
*
|
|
* Return: Non-negative on success / Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Saturday, November 8, 2003
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_mem_str_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hbool_t *isnull)
|
|
{
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
char *s = *(char **)_vl; /* Pointer to the user's string information */
|
|
#else
|
|
char *s = NULL; /* Pointer to the user's string information */
|
|
#endif
|
|
|
|
FUNC_ENTER_STATIC_NOERR
|
|
|
|
#ifndef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
H5MM_memcpy(&s, _vl, sizeof(char *));
|
|
#endif
|
|
|
|
*isnull = (s == NULL ? TRUE : FALSE);
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
|
} /* end H5T__vlen_mem_str_isnull() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_mem_str_setnull
|
|
*
|
|
* Purpose: Sets a VL info object in memory to the "null" value
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Saturday, November 8, 2003
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_mem_str_setnull(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void H5_ATTR_UNUSED *_bg)
|
|
{
|
|
char *t = NULL; /* Pointer to temporary buffer allocated */
|
|
|
|
FUNC_ENTER_STATIC_NOERR
|
|
|
|
/* Set pointer in user's buffer with memcpy, to avoid alignment issues */
|
|
H5MM_memcpy(_vl, &t, sizeof(char *));
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED) /*lint !e429 The pointer in 't' has been copied */
|
|
} /* end H5T__vlen_mem_str_setnull() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_mem_str_read
|
|
*
|
|
* Purpose: "Reads" the memory based VL string into a buffer
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Wednesday, June 2, 1999
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_mem_str_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, size_t len)
|
|
{
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
char *s = *(char **)_vl; /* Pointer to the user's string information */
|
|
#else
|
|
char *s; /* Pointer to the user's string information */
|
|
#endif
|
|
|
|
FUNC_ENTER_STATIC_NOERR
|
|
|
|
if (len > 0) {
|
|
/* check parameters */
|
|
HDassert(buf);
|
|
#ifdef H5_NO_ALIGNMENT_RESTRICTIONS
|
|
HDassert(s);
|
|
#else
|
|
HDassert(_vl);
|
|
H5MM_memcpy(&s, _vl, sizeof(char *));
|
|
#endif
|
|
|
|
H5MM_memcpy(buf, s, len);
|
|
} /* end if */
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
|
} /* end H5T__vlen_mem_str_read() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_mem_str_write
|
|
*
|
|
* Purpose: "Writes" the memory based VL string from a buffer
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Wednesday, June 2, 1999
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_mem_str_write(H5VL_object_t H5_ATTR_UNUSED *file, const H5T_vlen_alloc_info_t *vl_alloc_info,
|
|
void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size)
|
|
{
|
|
char * t; /* Pointer to temporary buffer allocated */
|
|
size_t len; /* Maximum length of the string to copy */
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
|
|
|
FUNC_ENTER_STATIC
|
|
|
|
/* check parameters */
|
|
HDassert(buf);
|
|
|
|
/* Use the user's memory allocation routine if one is defined */
|
|
if (vl_alloc_info->alloc_func != NULL) {
|
|
if (NULL ==
|
|
(t = (char *)(vl_alloc_info->alloc_func)((seq_len + 1) * base_size, vl_alloc_info->alloc_info)))
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL,
|
|
"application memory allocation routine failed for VL data")
|
|
} /* end if */
|
|
else /* Default to system malloc */
|
|
if (NULL == (t = (char *)HDmalloc((seq_len + 1) * base_size)))
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed for VL data")
|
|
|
|
/* 'write' the string into the buffer, with memcpy() */
|
|
len = (seq_len * base_size);
|
|
H5MM_memcpy(t, buf, len);
|
|
t[len] = '\0';
|
|
|
|
/* Set pointer in user's buffer with memcpy, to avoid alignment issues */
|
|
H5MM_memcpy(_vl, &t, sizeof(char *));
|
|
|
|
done:
|
|
FUNC_LEAVE_NOAPI(ret_value) /*lint !e429 The pointer in 't' has been copied */
|
|
} /* end H5T__vlen_mem_str_write() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_disk_getlen
|
|
*
|
|
* Purpose: Retrieves the length of a disk based VL element.
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Wednesday, June 2, 1999
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_disk_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, size_t *seq_len)
|
|
{
|
|
const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */
|
|
|
|
FUNC_ENTER_STATIC_NOERR
|
|
|
|
/* Check parameters */
|
|
HDassert(vl);
|
|
HDassert(seq_len);
|
|
|
|
/* Get length of sequence (different from blob size) */
|
|
UINT32DECODE(vl, *seq_len);
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
|
} /* end H5T__vlen_disk_getlen() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_disk_isnull
|
|
*
|
|
* Purpose: Checks if a disk VL info object is the "nil" object
|
|
*
|
|
* Return: Non-negative on success / Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Saturday, November 8, 2003
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_disk_isnull(const H5VL_object_t *file, void *_vl, hbool_t *isnull)
|
|
{
|
|
H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */
|
|
uint8_t * vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
|
|
|
FUNC_ENTER_STATIC
|
|
|
|
/* Check parameters */
|
|
HDassert(file);
|
|
HDassert(vl);
|
|
HDassert(isnull);
|
|
|
|
/* Skip the sequence's length */
|
|
vl += 4;
|
|
|
|
/* Set up VOL callback arguments */
|
|
vol_cb_args.op_type = H5VL_BLOB_ISNULL;
|
|
vol_cb_args.args.is_null.isnull = isnull;
|
|
|
|
/* Check if blob ID is "nil" */
|
|
if (H5VL_blob_specific(file, vl, &vol_cb_args) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to check if a blob ID is 'nil'")
|
|
|
|
done:
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
} /* end H5T__vlen_disk_isnull() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_disk_setnull
|
|
*
|
|
* Purpose: Sets a VL info object on disk to the "nil" value
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Saturday, November 8, 2003
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_disk_setnull(H5VL_object_t *file, void *_vl, void *bg)
|
|
{
|
|
H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */
|
|
uint8_t * vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
|
|
|
FUNC_ENTER_STATIC
|
|
|
|
/* check parameters */
|
|
HDassert(file);
|
|
HDassert(vl);
|
|
|
|
/* Free heap object for old data */
|
|
if (bg != NULL)
|
|
/* Delete sequence in destination location */
|
|
if (H5T__vlen_disk_delete(file, bg) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to remove background heap object")
|
|
|
|
/* Set the length of the sequence */
|
|
UINT32ENCODE(vl, 0);
|
|
|
|
/* Set up VOL callback arguments */
|
|
vol_cb_args.op_type = H5VL_BLOB_SETNULL;
|
|
|
|
/* Set blob ID to "nil" */
|
|
if (H5VL_blob_specific(file, vl, &vol_cb_args) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set a blob ID to 'nil'")
|
|
|
|
done:
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
} /* end H5T__vlen_disk_setnull() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_disk_read
|
|
*
|
|
* Purpose: Reads the disk based VL element into a buffer
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Wednesday, June 2, 1999
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_disk_read(H5VL_object_t *file, void *_vl, void *buf, size_t len)
|
|
{
|
|
const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
|
|
|
FUNC_ENTER_STATIC
|
|
|
|
/* Check parameters */
|
|
HDassert(file);
|
|
HDassert(vl);
|
|
HDassert(buf);
|
|
|
|
/* Skip the length of the sequence */
|
|
vl += 4;
|
|
|
|
/* Retrieve blob */
|
|
if (H5VL_blob_get(file, vl, buf, len, NULL) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get blob")
|
|
|
|
done:
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
} /* end H5T__vlen_disk_read() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_disk_write
|
|
*
|
|
* Purpose: Writes the disk based VL element from a buffer
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Wednesday, June 2, 1999
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_disk_write(H5VL_object_t *file, const H5T_vlen_alloc_info_t H5_ATTR_UNUSED *vl_alloc_info,
|
|
void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size)
|
|
{
|
|
uint8_t * vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */
|
|
const uint8_t *bg = (const uint8_t *)_bg; /* Pointer to the old data hvl_t */
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
|
|
|
FUNC_ENTER_STATIC
|
|
|
|
/* check parameters */
|
|
HDassert(vl);
|
|
HDassert(seq_len == 0 || buf);
|
|
HDassert(file);
|
|
|
|
/* Free heap object for old data, if non-NULL */
|
|
if (bg != NULL)
|
|
if (H5T__vlen_disk_delete(file, bg) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to remove background heap object")
|
|
|
|
/* Set the length of the sequence */
|
|
UINT32ENCODE(vl, seq_len);
|
|
|
|
/* Store blob */
|
|
if (H5VL_blob_put(file, buf, (seq_len * base_size), vl, NULL) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to put blob")
|
|
|
|
done:
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
} /* end H5T__vlen_disk_write() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_disk_delete
|
|
*
|
|
* Purpose: Deletes a disk-based VL element
|
|
*
|
|
* Return: Non-negative on success / Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Friday, August 15, 2019
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
static herr_t
|
|
H5T__vlen_disk_delete(H5VL_object_t *file, const void *_vl)
|
|
{
|
|
const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the user's hvl_t information */
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
|
|
|
FUNC_ENTER_STATIC
|
|
|
|
/* Check parameters */
|
|
HDassert(file);
|
|
|
|
/* Free heap object for old data */
|
|
if (vl != NULL) {
|
|
size_t seq_len; /* VL sequence's length */
|
|
|
|
/* Get length of sequence */
|
|
UINT32DECODE(vl, seq_len);
|
|
|
|
/* Delete object, if length > 0 */
|
|
if (seq_len > 0) {
|
|
H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */
|
|
|
|
/* Set up VOL callback arguments */
|
|
vol_cb_args.op_type = H5VL_BLOB_DELETE;
|
|
|
|
if (H5VL_blob_specific(file, (void *)vl, &vol_cb_args) < 0) /* Casting away 'const' OK -QAK */
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob")
|
|
} /* end if */
|
|
} /* end if */
|
|
|
|
done:
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
} /* end H5T__vlen_disk_delete() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T__vlen_reclaim
|
|
*
|
|
* Purpose: Internal recursive routine to free VL datatypes
|
|
*
|
|
* Return: Non-negative on success / Negative on failure
|
|
*
|
|
* Programmer: Quincey Koziol
|
|
* Friday, August 15, 2019
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
herr_t
|
|
H5T__vlen_reclaim(void *elem, const H5T_t *dt, H5T_vlen_alloc_info_t *alloc_info)
|
|
{
|
|
unsigned u; /* Local index variable */
|
|
H5MM_free_t free_func; /* Free function */
|
|
void * free_info; /* Free info */
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
|
|
|
FUNC_ENTER_NOAPI(FAIL)
|
|
|
|
/* Sanity checks */
|
|
HDassert(elem);
|
|
HDassert(dt);
|
|
HDassert(alloc_info);
|
|
|
|
free_func = alloc_info->free_func;
|
|
free_info = alloc_info->free_info;
|
|
|
|
/* Check the datatype of this element */
|
|
switch (dt->shared->type) {
|
|
case H5T_ARRAY:
|
|
/* Recurse on each element, if the array's base type is array, VL, enum or compound */
|
|
if (H5T_IS_COMPLEX(dt->shared->parent->shared->type)) {
|
|
void *off; /* offset of field */
|
|
|
|
/* Calculate the offset member and recurse on it */
|
|
for (u = 0; u < dt->shared->u.array.nelem; u++) {
|
|
off = ((uint8_t *)elem) + u * (dt->shared->parent->shared->size);
|
|
if (H5T_reclaim_cb(off, dt->shared->parent, 0, NULL, alloc_info) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free array element")
|
|
} /* end for */
|
|
} /* end if */
|
|
break;
|
|
|
|
case H5T_COMPOUND:
|
|
/* Check each field and recurse on VL, compound, enum or array ones */
|
|
for (u = 0; u < dt->shared->u.compnd.nmembs; u++) {
|
|
/* Recurse if it's VL, compound, enum or array */
|
|
if (H5T_IS_COMPLEX(dt->shared->u.compnd.memb[u].type->shared->type)) {
|
|
void *off; /* offset of field */
|
|
|
|
/* Calculate the offset member and recurse on it */
|
|
off = ((uint8_t *)elem) + dt->shared->u.compnd.memb[u].offset;
|
|
if (H5T_reclaim_cb(off, dt->shared->u.compnd.memb[u].type, 0, NULL, alloc_info) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free compound field")
|
|
} /* end if */
|
|
} /* end for */
|
|
break;
|
|
|
|
case H5T_VLEN:
|
|
/* Recurse on the VL information if it's VL, compound, enum or array, then free VL sequence */
|
|
if (dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) {
|
|
hvl_t *vl = (hvl_t *)elem; /* Temp. ptr to the vl info */
|
|
|
|
/* Check if there is anything actually in this sequence */
|
|
if (vl->len != 0) {
|
|
/* Recurse if it's VL, array, enum or compound */
|
|
if (H5T_IS_COMPLEX(dt->shared->parent->shared->type)) {
|
|
void *off; /* offset of field */
|
|
|
|
/* Calculate the offset of each array element and recurse on it */
|
|
while (vl->len > 0) {
|
|
off = ((uint8_t *)vl->p) + (vl->len - 1) * dt->shared->parent->shared->size;
|
|
if (H5T_reclaim_cb(off, dt->shared->parent, 0, NULL, alloc_info) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free VL element")
|
|
vl->len--;
|
|
} /* end while */
|
|
} /* end if */
|
|
|
|
/* Free the VL sequence */
|
|
if (free_func != NULL)
|
|
(*free_func)(vl->p, free_info);
|
|
else
|
|
HDfree(vl->p);
|
|
} /* end if */
|
|
}
|
|
else if (dt->shared->u.vlen.type == H5T_VLEN_STRING) {
|
|
/* Free the VL string */
|
|
if (free_func != NULL)
|
|
(*free_func)(*(char **)elem, free_info);
|
|
else
|
|
HDfree(*(char **)elem);
|
|
}
|
|
else {
|
|
HDassert(0 && "Invalid VL type");
|
|
} /* end else */
|
|
break;
|
|
|
|
/* Don't do anything for simple types */
|
|
case H5T_INTEGER:
|
|
case H5T_FLOAT:
|
|
case H5T_TIME:
|
|
case H5T_STRING:
|
|
case H5T_BITFIELD:
|
|
case H5T_OPAQUE:
|
|
case H5T_ENUM:
|
|
break;
|
|
|
|
/* Should never have these values */
|
|
case H5T_REFERENCE:
|
|
case H5T_NO_CLASS:
|
|
case H5T_NCLASSES:
|
|
default:
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid VL datatype class")
|
|
break;
|
|
|
|
} /* end switch */ /*lint !e788 All appropriate cases are covered */
|
|
|
|
done:
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
} /* end H5T__vlen_reclaim() */
|
|
|
|
/*-------------------------------------------------------------------------
|
|
* Function: H5T_vlen_reclaim_elmt
|
|
*
|
|
* Purpose: Alternative method to reclaim any VL data for a buffer element.
|
|
*
|
|
* Use this function when the datatype is already available, but
|
|
* the allocation info is needed from the context before jumping
|
|
* into recursion.
|
|
*
|
|
* Return: Non-negative on success/Negative on failure
|
|
*
|
|
* Programmer: Mike McGreevy
|
|
* May 11, 2010
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
herr_t
|
|
H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt)
|
|
{
|
|
H5T_vlen_alloc_info_t vl_alloc_info; /* VL allocation info */
|
|
herr_t ret_value = SUCCEED; /* return value */
|
|
|
|
HDassert(dt);
|
|
HDassert(elem);
|
|
|
|
FUNC_ENTER_NOAPI(FAIL)
|
|
|
|
/* Get VL allocation info */
|
|
if (H5CX_get_vlen_alloc_info(&vl_alloc_info) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info")
|
|
|
|
/* Recurse on buffer to free dynamic fields */
|
|
if (H5T__vlen_reclaim(elem, dt, &vl_alloc_info) < 0)
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim vlen elements")
|
|
|
|
done:
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
} /* H5T_vlen_reclaim_elmt() */
|