diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5T.c | 9 | ||||
-rw-r--r-- | src/H5Tpublic.h | 7 |
2 files changed, 11 insertions, 5 deletions
@@ -1940,9 +1940,12 @@ H5Tset_size(hid_t type_id, size_t size) if (H5T_STATE_TRANSIENT!=dt->state) { HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only"); } - if (size <= 0) { + if (size <= 0 && size!=H5T_VARIABLE) { HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive"); } + if (size == H5T_VARIABLE && dt->type!=H5T_STRING) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "only strings may be variable length"); + } if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) { HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined"); @@ -3801,7 +3804,7 @@ H5Tget_member_value(hid_t type, int membno, void *value/*out*/) * *------------------------------------------------------------------------- */ -hid_t +herr_t H5Tenum_nameof(hid_t type, void *value, char *name/*out*/, size_t size) { H5T_t *dt = NULL; @@ -3851,7 +3854,7 @@ H5Tenum_nameof(hid_t type, void *value, char *name/*out*/, size_t size) * *------------------------------------------------------------------------- */ -hid_t +herr_t H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/) { H5T_t *dt = NULL; diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index e595da6..d9284f1 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -156,6 +156,9 @@ typedef struct { void *p; /* Pointer to VL data */ } hvl_t; +/* Variable Length String information */ +#define H5T_VARIABLE ((size_t)(-1)) /* Indicate that a string is variable length (null-terminated in C, instead of fixed length) */ + /* All data type conversion functions are... */ typedef herr_t (*H5T_conv_t) (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t stride, void *buf, @@ -460,9 +463,9 @@ __DLL__ herr_t H5Tpack(hid_t type_id); /* Operations defined on enumeration data types */ __DLL__ hid_t H5Tenum_create(hid_t base_id); __DLL__ herr_t H5Tenum_insert(hid_t type, const char *name, void *value); -__DLL__ hid_t H5Tenum_nameof(hid_t type, void *value, char *name/*out*/, +__DLL__ herr_t H5Tenum_nameof(hid_t type, void *value, char *name/*out*/, size_t size); -__DLL__ hid_t H5Tenum_valueof(hid_t type, const char *name, +__DLL__ herr_t H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/); /* Operations defined on variable-length data types */ |