summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Tconv.c8
-rw-r--r--test/tvlstr.c6
-rw-r--r--test/tvltypes.c70
3 files changed, 55 insertions, 29 deletions
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index f151a1a..534820b 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -2837,7 +2837,13 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
dst_size=seq_len*dst_base_size;
/* Check if conversion buffer is large enough, resize if
- * necessary */
+ * necessary. If the SEQ_LEN is 0, allocate a minimal size buffer. */
+ if(src_size==0 && dst_size==0) {
+ conv_buf_size=((1/H5T_VLEN_MIN_CONF_BUF_SIZE)+1)*H5T_VLEN_MIN_CONF_BUF_SIZE;
+ if((conv_buf=H5FL_BLK_REALLOC(vlen_seq,conv_buf, conv_buf_size))==NULL)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
+ }
+
if(conv_buf_size<MAX(src_size,dst_size)) {
/* Only allocate conversion buffer in H5T_VLEN_MIN_CONF_BUF_SIZE increments */
conv_buf_size=((MAX(src_size,dst_size)/H5T_VLEN_MIN_CONF_BUF_SIZE)+1)*H5T_VLEN_MIN_CONF_BUF_SIZE;
diff --git a/test/tvlstr.c b/test/tvlstr.c
index 8212206..a7b2a32 100644
--- a/test/tvlstr.c
+++ b/test/tvlstr.c
@@ -256,7 +256,7 @@ test_vlstrings_basic(void)
static void
test_vlstrings_special(void)
{
- const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"};
+ const char *wdata[SPACE1_DIM1] = {"one", "two", "", "\0"};
const char *wdata2[SPACE1_DIM1] = {NULL, NULL, NULL, NULL};
char *rdata[SPACE1_DIM1]; /* Information read in */
char *fill; /* Fill value */
@@ -314,6 +314,10 @@ test_vlstrings_special(void)
TestErrPrintf("VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",(int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i]));
continue;
} /* end if */
+ if((wdata[i]==NULL && rdata[i]!=NULL) || (rdata[i]==NULL && wdata[i]!=NULL)) {
+ TestErrPrintf("VL data values don't match!\n");
+ continue;
+ } /* end if */
if( HDstrcmp(wdata[i],rdata[i]) != 0 ) {
TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",(int)i,wdata[i],(int)i,rdata[i]);
continue;
diff --git a/test/tvltypes.c b/test/tvltypes.c
index de51f4a..b6a5509 100644
--- a/test/tvltypes.c
+++ b/test/tvltypes.c
@@ -2397,16 +2397,19 @@ static void
test_vltypes_fill_value(void)
{
typedef struct dtype1_struct {
- int i1;
- char *str;
- int i2;
- int i3;
- int i4;
- int i5;
- int i6;
- int i7;
- int i8;
- float f1;
+ unsigned int gui;
+ unsigned int pgui;
+ char *str_id;
+ char *str_name;
+ char *str_desc;
+ char *str_orig;
+ char *str_stat;
+ unsigned int ver;
+ double val;
+ double ma;
+ double mi;
+ char *str_form;
+ char *str_unit;
} dtype1_struct;
herr_t ret;
@@ -2417,7 +2420,7 @@ test_vltypes_fill_value(void)
hid_t dcpl_id, xfer_pid;
hid_t dset_id;
hsize_t dim1[] = {SPACE1_DIM1};
- const dtype1_struct fill1 = {1, "foobar", 2, 3, 4, 5, 6, 7, 8, 9.0};
+ const dtype1_struct fill1 = {1, 2, "foobar", "", NULL, "\0", "dead", 3, 4.0, 100.0, 1.0, "liquid", "meter"};
dtype1_struct buf[SPACE1_DIM1];
size_t mem_used=0; /* Memory used during allocation */
int i;
@@ -2429,41 +2432,54 @@ test_vltypes_fill_value(void)
dtype1_id = H5Tcreate(H5T_COMPOUND, sizeof(struct dtype1_struct));
CHECK(dtype1_id, FAIL, "H5Tcreate");
- ret = H5Tinsert(dtype1_id,"i1",HOFFSET(struct dtype1_struct,i1),H5T_NATIVE_INT);
+ ret = H5Tinsert(dtype1_id,"guid",HOFFSET(struct dtype1_struct,gui),H5T_NATIVE_UINT);
CHECK(ret, FAIL, "H5Tinsert");
+ ret = H5Tinsert(dtype1_id,"pguid",HOFFSET(struct dtype1_struct,pgui),H5T_NATIVE_UINT);
+ CHECK(ret, FAIL, "H5Tinsert");
+
+
str_id = H5Tcopy(H5T_C_S1);
CHECK(str_id, FAIL, "H5Tcopy");
ret = H5Tset_size(str_id,H5T_VARIABLE);
CHECK(ret, FAIL, "H5Tset_size");
- ret = H5Tinsert(dtype1_id,"vl_string",HOFFSET(dtype1_struct,str),str_id);
+ ret = H5Tinsert(dtype1_id,"str_id",HOFFSET(dtype1_struct,str_id),str_id);
+ CHECK(ret, FAIL, "H5Tinsert");
+
+ ret = H5Tinsert(dtype1_id,"str_name",HOFFSET(dtype1_struct,str_name),str_id);
+ CHECK(ret, FAIL, "H5Tinsert");
+
+ ret = H5Tinsert(dtype1_id,"str_desc",HOFFSET(dtype1_struct,str_desc),str_id);
CHECK(ret, FAIL, "H5Tinsert");
- ret = H5Tinsert(dtype1_id,"i2",HOFFSET(struct dtype1_struct,i2),H5T_NATIVE_INT);
+ ret = H5Tinsert(dtype1_id,"str_orig",HOFFSET(dtype1_struct,str_orig),str_id);
CHECK(ret, FAIL, "H5Tinsert");
- ret = H5Tinsert(dtype1_id,"i3",HOFFSET(struct dtype1_struct,i3),H5T_NATIVE_INT);
+ ret = H5Tinsert(dtype1_id,"str_stat",HOFFSET(dtype1_struct,str_stat),str_id);
CHECK(ret, FAIL, "H5Tinsert");
- ret = H5Tinsert(dtype1_id,"i4",HOFFSET(struct dtype1_struct,i4),H5T_NATIVE_INT);
+
+ ret = H5Tinsert(dtype1_id,"ver",HOFFSET(struct dtype1_struct,ver),H5T_NATIVE_UINT);
CHECK(ret, FAIL, "H5Tinsert");
- ret = H5Tinsert(dtype1_id,"i5",HOFFSET(struct dtype1_struct,i5),H5T_NATIVE_INT);
+ ret = H5Tinsert(dtype1_id,"val",HOFFSET(struct dtype1_struct,val),H5T_NATIVE_DOUBLE);
CHECK(ret, FAIL, "H5Tinsert");
- ret = H5Tinsert(dtype1_id,"i6",HOFFSET(struct dtype1_struct,i6),H5T_NATIVE_INT);
+ ret = H5Tinsert(dtype1_id,"ma",HOFFSET(struct dtype1_struct,ma),H5T_NATIVE_DOUBLE);
CHECK(ret, FAIL, "H5Tinsert");
- ret = H5Tinsert(dtype1_id,"i7",HOFFSET(struct dtype1_struct,i7),H5T_NATIVE_INT);
+ ret = H5Tinsert(dtype1_id,"mi",HOFFSET(struct dtype1_struct,mi),H5T_NATIVE_DOUBLE);
CHECK(ret, FAIL, "H5Tinsert");
- ret = H5Tinsert(dtype1_id,"i8",HOFFSET(struct dtype1_struct,i8),H5T_NATIVE_INT);
+
+ ret = H5Tinsert(dtype1_id,"str_form",HOFFSET(dtype1_struct,str_form),str_id);
CHECK(ret, FAIL, "H5Tinsert");
- ret = H5Tinsert(dtype1_id,"f1",HOFFSET(struct dtype1_struct,f1),H5T_NATIVE_FLOAT);
+ ret = H5Tinsert(dtype1_id,"str_unit",HOFFSET(dtype1_struct,str_unit),str_id);
CHECK(ret, FAIL, "H5Tinsert");
+
ret = H5Tclose(str_id);
CHECK(ret, FAIL, "H5Tclose");
@@ -2526,9 +2542,9 @@ test_vltypes_fill_value(void)
/* Compare data read in */
for(i=0; i<SPACE1_DIM1; i++) {
- if(strcmp(buf[i].str, "foobar")) {
- TestErrPrintf("%d: VL data doesn't match!, buf[%d].str=%s\n",__LINE__,(int)i,buf[i].str);
- /*continue;*/
+ if(strcmp(buf[i].str_id, "foobar") || strcmp(buf[i].str_name, "") || buf[i].str_desc || strcmp(buf[i].str_orig,"\0") || strcmp(buf[i].str_stat, "dead") || strcmp(buf[i].str_form, "liquid") || strcmp(buf[i].str_unit, "meter")) {
+ TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i);
+ continue;
} /* end if */
} /* end for */
@@ -2548,9 +2564,9 @@ test_vltypes_fill_value(void)
/* Compare data read in */
for(i=0; i<SPACE1_DIM1; i++) {
- if(strcmp(buf[i].str, "foobar")) {
- TestErrPrintf("%d: VL data doesn't match!, buf[%d].str=%s\n",__LINE__,(int)i,buf[i].str);
- /*continue;*/
+ if(strcmp(buf[i].str_id, "foobar") || strcmp(buf[i].str_name, "") || buf[i].str_desc || strcmp(buf[i].str_orig,"\0") || strcmp(buf[i].str_stat, "dead") || strcmp(buf[i].str_form, "liquid") || strcmp(buf[i].str_unit, "meter")) {
+ TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i);
+ continue;
} /* end if */
} /* end for */