summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-07-23 19:58:23 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-07-23 19:58:23 (GMT)
commit89f283e2e47814419e7e6861bfa76f56e27124d2 (patch)
tree1b2d15454e2a6138108a76508ab4327b0e0d4e80
parentd0d4aafe70b220148affc05d926ed0dd1c77986c (diff)
downloadhdf5-89f283e2e47814419e7e6861bfa76f56e27124d2.zip
hdf5-89f283e2e47814419e7e6861bfa76f56e27124d2.tar.gz
hdf5-89f283e2e47814419e7e6861bfa76f56e27124d2.tar.bz2
[svn-r11146] Purpose:
Bug fix Description: If a named datatype is copied and the copy is used to create a dataset, the dataset would inadvertantly refer to the original named datatype instead of a local (possibly modified) copy of the named datatype. Solution: Fixed datatype copying routine. Platforms tested: FreeBSD 4.11 (sleipnir) Too minor to require h5committest
-rw-r--r--release_docs/RELEASE.txt3
-rw-r--r--src/H5Odtype.c4
-rw-r--r--src/H5T.c42
-rw-r--r--test/dtypes.c114
4 files changed, 105 insertions, 58 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 982345c..6cdf888 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -72,6 +72,9 @@ Bug Fixes since HDF5-1.6.4 release
Library
-------
+ - Fixed a bug with named datatypes where a copy of a named datatype
+ used to create a dataset would accidentally use the original
+ named datatype for the dataset's datatype. QAK - 2005/07/23
- Made H5Fget_name() be consistent and always return name of actual
file the ID is in. (Instead of the name of the top file in a
file mounting hierarchy). QAK - 2005/07/19
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index ed044c4..bf3cd1e 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -1131,8 +1131,8 @@ H5O_dtype_get_share(H5F_t UNUSED *f, const void *_mesg,
assert (sh);
if (H5F_addr_defined (dt->ent.header)) {
- if(H5T_STATE_NAMED!=dt->shared->state && H5T_STATE_OPEN!=dt->shared->state && H5T_STATE_TRANSIENT!=dt->shared->state)
- HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "datatype state is not valid");
+ /* If the address is defined, this had better be a named datatype */
+ HDassert (H5T_STATE_NAMED==dt->shared->state || H5T_STATE_OPEN==dt->shared->state);
sh->in_gh = FALSE;
sh->u.ent = dt->ent;
diff --git a/src/H5T.c b/src/H5T.c
index a1c6c65..215dce7 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -429,10 +429,11 @@ static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src,
/* Allocate new datatype info */ \
if (NULL==(dt = H5FL_CALLOC(H5T_t))) \
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") \
- if (NULL==(dt->shared = H5FL_CALLOC(H5T_shared_t))) { \
- H5FL_FREE(H5T_t, dt); \
+ dt->ent.header = HADDR_UNDEF; \
+ if (NULL==(dt->shared = H5FL_CALLOC(H5T_shared_t))) { \
+ H5FL_FREE(H5T_t, dt); \
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") \
- } \
+ } \
}
@@ -2630,6 +2631,7 @@ H5T_create(H5T_class_t type, size_t size)
case H5T_COMPOUND:
if (NULL==(dt = H5FL_CALLOC(H5T_t)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ dt->ent.header = HADDR_UNDEF;
if (NULL==(dt->shared = H5FL_CALLOC(H5T_shared_t)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
dt->shared->type = type;
@@ -2658,6 +2660,7 @@ H5T_create(H5T_class_t type, size_t size)
}
if (NULL==(dt = H5FL_CALLOC(H5T_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ dt->ent.header = HADDR_UNDEF;
if (NULL==(dt->shared = H5FL_CALLOC(H5T_shared_t)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
dt->shared->type = type;
@@ -2911,8 +2914,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
if (NULL==(new_dt->shared = H5FL_MALLOC(H5T_shared_t)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- /* Copy actual information */
- new_dt->ent = old_dt->ent;
+ /* Copy shared information (entry information is copied last) */
*(new_dt->shared) = *(old_dt->shared);
/* Copy parent information */
@@ -2926,8 +2928,6 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
* Return an unlocked transient type.
*/
new_dt->shared->state = H5T_STATE_TRANSIENT;
- HDmemset (&(new_dt->ent), 0, sizeof(new_dt->ent));
- new_dt->ent.header = HADDR_UNDEF;
break;
case H5T_COPY_ALL:
@@ -2935,9 +2935,9 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
* Return a transient type (locked or unlocked) or an unopened named
* type. Immutable transient types are degraded to read-only.
*/
- if (H5T_STATE_OPEN==new_dt->shared->state) {
+ if (H5T_STATE_OPEN==old_dt->shared->state) {
new_dt->shared->state = H5T_STATE_NAMED;
- } else if (H5T_STATE_IMMUTABLE==new_dt->shared->state) {
+ } else if (H5T_STATE_IMMUTABLE==old_dt->shared->state) {
new_dt->shared->state = H5T_STATE_RDONLY;
}
break;
@@ -2947,15 +2947,20 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
* Return a transient type (locked or unlocked) or an opened named
* type. Immutable transient types are degraded to read-only.
*/
- if (H5F_addr_defined(new_dt->ent.header)) {
+ if (H5F_addr_defined(old_dt->ent.header)) {
/* Check if the object is already open */
- if((reopened_fo=H5FO_opened(new_dt->ent.file,new_dt->ent.header))==NULL) {
+ if((reopened_fo=H5FO_opened(old_dt->ent.file, old_dt->ent.header))==NULL) {
/* Clear any errors from H5FO_opened() */
H5E_clear();
- if (H5O_open (&(new_dt->ent))<0)
+
+ /* Open named datatype again */
+ if (H5O_open (&(old_dt->ent))<0)
HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type");
- if(H5FO_insert(new_dt->ent.file, new_dt->ent.header,new_dt->shared)<0)
+
+ /* Insert opened named datatype into opened object list for the file */
+ if(H5FO_insert(old_dt->ent.file, old_dt->ent.header, new_dt->shared)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects")
+
new_dt->shared->fo_count=1;
} else {
/* The object is already open. Free the H5T_shared_t struct
@@ -2966,7 +2971,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
reopened_fo->fo_count++;
}
new_dt->shared->state = H5T_STATE_OPEN;
- } else if (H5T_STATE_IMMUTABLE==new_dt->shared->state) {
+ } else if (H5T_STATE_IMMUTABLE==old_dt->shared->state) {
new_dt->shared->state = H5T_STATE_RDONLY;
}
break;
@@ -3078,9 +3083,16 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
} /* end switch */
/* Deep copy of the symbol table entry, if there was one */
- if (H5F_addr_defined(old_dt->ent.header))
+ if ( new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) {
+ if (!H5F_addr_defined(old_dt->ent.header))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "named dataype with invalid address");
if (H5G_ent_copy(&(new_dt->ent), &(old_dt->ent),H5G_COPY_DEEP)<0)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to copy entry");
+ } /* end if */
+ else {
+ HDmemset (&(new_dt->ent), 0, sizeof(new_dt->ent));
+ new_dt->ent.header = HADDR_UNDEF;
+ } /* end else */
/* Set return value */
ret_value=new_dt;
diff --git a/test/dtypes.c b/test/dtypes.c
index 7d870df..6fccd25 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -342,8 +342,8 @@ test_classes(void)
hid_t vls_id; /* VL string */
hid_t memb_id; /* Compound member datatype */
H5T_class_t memb_cls;
- H5T_class_t tcls;
- int nmembs, i;
+ H5T_class_t tcls;
+ unsigned int nmembs, i;
TESTING("H5Tget_class()");
@@ -723,9 +723,9 @@ test_compound_2(void)
TESTING("compound element reordering");
/* Sizes should be the same, but be careful just in case */
- buf = malloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
- bkg = malloc(nelmts * sizeof(struct dt));
- orig = malloc(nelmts * sizeof(struct st));
+ buf = (unsigned char*)malloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
+ bkg = (unsigned char*)malloc(nelmts * sizeof(struct dt));
+ orig = (unsigned char*)malloc(nelmts * sizeof(struct st));
for (i=0; i<(int)nelmts; i++) {
s_ptr = ((struct st*)orig) + i;
s_ptr->a = i*8+0;
@@ -840,9 +840,9 @@ test_compound_3(void)
TESTING("compound subset conversions");
/* Initialize */
- buf = malloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
- bkg = malloc(nelmts * sizeof(struct dt));
- orig = malloc(nelmts * sizeof(struct st));
+ buf = (unsigned char*)malloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
+ bkg = (unsigned char*)malloc(nelmts * sizeof(struct dt));
+ orig = (unsigned char*)malloc(nelmts * sizeof(struct st));
for (i=0; i<(int)nelmts; i++) {
s_ptr = ((struct st*)orig) + i;
s_ptr->a = i*8+0;
@@ -958,9 +958,9 @@ test_compound_4(void)
TESTING("compound element shrinking & reordering");
/* Sizes should be the same, but be careful just in case */
- buf = malloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
- bkg = malloc(nelmts * sizeof(struct dt));
- orig = malloc(nelmts * sizeof(struct st));
+ buf = (unsigned char*)malloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
+ bkg = (unsigned char*)malloc(nelmts * sizeof(struct dt));
+ orig = (unsigned char*)malloc(nelmts * sizeof(struct st));
for (i=0; i<(int)nelmts; i++) {
s_ptr = ((struct st*)orig) + i;
s_ptr->a = i*8+0;
@@ -1187,9 +1187,9 @@ test_compound_6(void)
TESTING("compound element growing");
/* Sizes should be the same, but be careful just in case */
- buf = malloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
- bkg = malloc(nelmts * sizeof(struct dt));
- orig = malloc(nelmts * sizeof(struct st));
+ buf = (unsigned char*)malloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
+ bkg = (unsigned char*)malloc(nelmts * sizeof(struct dt));
+ orig = (unsigned char*)malloc(nelmts * sizeof(struct st));
for (i=0; i<(int)nelmts; i++) {
s_ptr = ((struct st*)orig) + i;
s_ptr->b = (i*8+1) & 0x7fff;
@@ -2028,19 +2028,23 @@ test_compound_11(void)
/* Verify converted buffer is correct */
for(u=0; u<NTESTELEM; u++) {
if(((big_t *)buf_orig)[u].d1!=((little_t *)buf)[u].d1) {
- printf("Error, line #%d: buf_orig[%u].d1=%f, buf[%u].d1=%f\n",__LINE__,(unsigned)u,((big_t *)buf_orig)[u].d1,(unsigned)u,((little_t *)buf)[u].d1);
+ printf("Error, line #%d: buf_orig[%u].d1=%f, buf[%u].d1=%f\n",__LINE__,
+ (unsigned)u,((big_t *)buf_orig)[u].d1,(unsigned)u,((little_t *)buf)[u].d1);
TEST_ERROR
} /* end if */
if(((big_t *)buf_orig)[u].i1!=((little_t *)buf)[u].i1) {
- printf("Error, line #%d: buf_orig[%u].i1=%d, buf[%u].i1=%d\n",__LINE__,(unsigned)u,((big_t *)buf_orig)[u].i1,(unsigned)u,((little_t *)buf)[u].i1);
+ printf("Error, line #%d: buf_orig[%u].i1=%d, buf[%u].i1=%d\n",__LINE__,
+ (unsigned)u,((big_t *)buf_orig)[u].i1,(unsigned)u,((little_t *)buf)[u].i1);
TEST_ERROR
} /* end if */
if(((big_t *)buf_orig)[u].s1==NULL || ((little_t *)buf)[u].s1==NULL) {
- printf("Error, line #%d: buf_orig[%u].s1=%p, buf[%u].s1=%p\n",__LINE__,(unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1);
+ printf("Error, line #%d: buf_orig[%u].s1=%p, buf[%u].s1=%p\n",__LINE__,
+ (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1);
TEST_ERROR
} /* end if */
else if(HDstrcmp(((big_t *)buf_orig)[u].s1,((little_t *)buf)[u].s1)) {
- printf("Error, line #%d: buf_orig[%u].s1=%s, buf[%u].s1=%s\n",__LINE__,(unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1);
+ printf("Error, line #%d: buf_orig[%u].s1=%s, buf[%u].s1=%s\n",__LINE__,
+ (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1);
TEST_ERROR
} /* end if */
HDfree(((little_t *)buf)[u].s1);
@@ -2064,19 +2068,23 @@ test_compound_11(void)
/* Verify converted buffer is correct */
for(u=0; u<NTESTELEM; u++) {
if(((big_t *)buf_orig)[u].d1!=((little_t *)buf)[u].d1) {
- printf("Error, line #%d: buf_orig[%u].d1=%f, buf[%u].d1=%f\n",__LINE__,(unsigned)u,((big_t *)buf_orig)[u].d1,(unsigned)u,((little_t *)buf)[u].d1);
+ printf("Error, line #%d: buf_orig[%u].d1=%f, buf[%u].d1=%f\n",__LINE__,
+ (unsigned)u,((big_t *)buf_orig)[u].d1,(unsigned)u,((little_t *)buf)[u].d1);
TEST_ERROR
} /* end if */
if(((big_t *)buf_orig)[u].i1!=((little_t *)buf)[u].i1) {
- printf("Error, line #%d: buf_orig[%u].i1=%d, buf[%u].i1=%d\n",__LINE__,(unsigned)u,((big_t *)buf_orig)[u].i1,(unsigned)u,((little_t *)buf)[u].i1);
+ printf("Error, line #%d: buf_orig[%u].i1=%d, buf[%u].i1=%d\n",__LINE__,
+ (unsigned)u,((big_t *)buf_orig)[u].i1,(unsigned)u,((little_t *)buf)[u].i1);
TEST_ERROR
} /* end if */
if(((big_t *)buf_orig)[u].s1==NULL || ((little_t *)buf)[u].s1==NULL) {
- printf("Error, line #%d: buf_orig[%u].s1=%p, buf[%u].s1=%p\n",__LINE__,(unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1);
+ printf("Error, line #%d: buf_orig[%u].s1=%p, buf[%u].s1=%p\n",__LINE__,
+ (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1);
TEST_ERROR
} /* end if */
else if(HDstrcmp(((big_t *)buf_orig)[u].s1,((little_t *)buf)[u].s1)) {
- printf("Error, line #%d: buf_orig[%u].s1=%s, buf[%u].s1=%s\n",__LINE__,(unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1);
+ printf("Error, line #%d: buf_orig[%u].s1=%s, buf[%u].s1=%s\n",__LINE__,
+ (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1);
TEST_ERROR
} /* end if */
HDfree(((little_t *)buf)[u].s1);
@@ -2094,19 +2102,23 @@ test_compound_11(void)
/* Verify converted buffer is correct */
for(u=0; u<NTESTELEM; u++) {
if(((big_t *)buf_orig)[u].d1!=((little_t *)buf)[u].d1) {
- printf("Error, line #%d: buf_orig[%u].d1=%f, buf[%u].d1=%f\n",__LINE__,(unsigned)u,((big_t *)buf_orig)[u].d1,(unsigned)u,((little_t *)buf)[u].d1);
+ printf("Error, line #%d: buf_orig[%u].d1=%f, buf[%u].d1=%f\n",__LINE__,
+ (unsigned)u,((big_t *)buf_orig)[u].d1,(unsigned)u,((little_t *)buf)[u].d1);
TEST_ERROR
} /* end if */
if(((big_t *)buf_orig)[u].i1!=((little_t *)buf)[u].i1) {
- printf("Error, line #%d: buf_orig[%u].i1=%d, buf[%u].i1=%d\n",__LINE__,(unsigned)u,((big_t *)buf_orig)[u].i1,(unsigned)u,((little_t *)buf)[u].i1);
+ printf("Error, line #%d: buf_orig[%u].i1=%d, buf[%u].i1=%d\n",__LINE__,
+ (unsigned)u,((big_t *)buf_orig)[u].i1,(unsigned)u,((little_t *)buf)[u].i1);
TEST_ERROR
} /* end if */
if(((big_t *)buf_orig)[u].s1==NULL || ((little_t *)buf)[u].s1==NULL) {
- printf("Error, line #%d: buf_orig[%u].s1=%p, buf[%u].s1=%p\n",__LINE__,(unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1);
+ printf("Error, line #%d: buf_orig[%u].s1=%p, buf[%u].s1=%p\n",__LINE__,
+ (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1);
TEST_ERROR
} /* end if */
else if(HDstrcmp(((big_t *)buf_orig)[u].s1,((little_t *)buf)[u].s1)) {
- printf("Error, line #%d: buf_orig[%u].s1=%s, buf[%u].s1=%s\n",__LINE__,(unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1);
+ printf("Error, line #%d: buf_orig[%u].s1=%s, buf[%u].s1=%s\n",__LINE__,
+ (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1);
TEST_ERROR
} /* end if */
HDfree(((little_t *)buf)[u].s1);
@@ -2329,7 +2341,7 @@ test_query(void)
goto error;
} /* end if */
- /* Query member number and member index by name, for enumeration type. */
+ /* Query member number and member index by member name, for enumeration type. */
if(H5Tget_nmembers(tid2)!=5) {
H5_FAILED();
printf("Can't get member number\n");
@@ -3289,7 +3301,7 @@ test_transient (hid_t fapl)
static int
test_named (hid_t fapl)
{
- hid_t file=-1, type=-1, space=-1, dset=-1, t2=-1, attr1=-1;
+ hid_t file=-1, type=-1, space=-1, dset=-1, t2=-1, t3=-1, attr1=-1;
herr_t status;
static hsize_t ds_size[2] = {10, 20};
hsize_t i,j;
@@ -3413,9 +3425,7 @@ test_named (hid_t fapl)
* first dataset.
*/
if (H5Dclose (dset)<0) goto error;
- if ((dset=H5Dcreate (file, "dset2", t2, space, H5P_DEFAULT))<0) {
- goto error;
- }
+ if ((dset=H5Dcreate (file, "dset2", t2, space, H5P_DEFAULT))<0) goto error;
/* Reopen the second dataset and make sure the type is shared */
if (H5Tclose (t2)<0) goto error;
@@ -3437,9 +3447,30 @@ test_named (hid_t fapl)
if ((t2=H5Tcopy (dset))<0) goto error;
if (H5Tset_precision (t2, 256)<0) goto error;
if (H5Tclose (t2)<0) goto error;
+ if (H5Dclose (dset)<0) goto error;
- /* Clean up */
+ /*
+ * Copy of committed type used as dataset type should not be name type
+ */
+ if ((t2 = H5Tcopy (type))<0) goto error;
+ if ((status=H5Tcommitted (t2))<0) goto error;
+ if (status) {
+ H5_FAILED();
+ HDputs (" Copied type should not be a named type!");
+ goto error;
+ }
+ if ((dset=H5Dcreate (file, "dset3", t2, space, H5P_DEFAULT))<0) goto error;
+ if ((t3 = H5Dget_type (dset))<0) goto error;
+ if ((status=H5Tcommitted (t3))<0) goto error;
+ if (status) {
+ H5_FAILED();
+ HDputs (" Datatype from dataset using copied type should not be a named type!");
+ goto error;
+ }
+ if (H5Tclose (t3)<0) goto error;
if (H5Dclose (dset)<0) goto error;
+
+ /* Clean up */
if (H5Tclose (type)<0) goto error;
if (H5Sclose (space)<0) goto error;
if (H5Fclose (file)<0) goto error;
@@ -3448,6 +3479,7 @@ test_named (hid_t fapl)
error:
H5E_BEGIN_TRY {
+ H5Tclose (t3);
H5Tclose (t2);
H5Tclose (type);
H5Sclose (space);
@@ -3516,7 +3548,7 @@ test_conv_str_1(void)
*/
src_type = mkstr(10, H5T_STR_NULLTERM);
dst_type = mkstr(5, H5T_STR_NULLTERM);
- buf = HDcalloc(2, 10);
+ buf = (char*)HDcalloc(2, 10);
HDmemcpy(buf, "abcdefghi\0abcdefghi\0", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (HDmemcmp(buf, "abcd\0abcd\0abcdefghi\0", 20)) {
@@ -3539,7 +3571,7 @@ test_conv_str_1(void)
*/
src_type = mkstr(10, H5T_STR_NULLPAD);
dst_type = mkstr(5, H5T_STR_NULLPAD);
- buf = HDcalloc(2, 10);
+ buf = (char*)HDcalloc(2, 10);
HDmemcpy(buf, "abcdefghijabcdefghij", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (HDmemcmp(buf, "abcdeabcdeabcdefghij", 20)) {
@@ -3562,7 +3594,7 @@ test_conv_str_1(void)
*/
src_type = mkstr(10, H5T_STR_SPACEPAD);
dst_type = mkstr(5, H5T_STR_SPACEPAD);
- buf = HDcalloc(2, 10);
+ buf = (char*)HDcalloc(2, 10);
HDmemcpy(buf, "abcdefghijabcdefghij", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (HDmemcmp(buf, "abcdeabcdeabcdefghij", 20)) {
@@ -3588,7 +3620,7 @@ test_conv_str_1(void)
*/
src_type = mkstr(10, H5T_STR_NULLTERM);
dst_type = mkstr(10, H5T_STR_NULLTERM);
- buf = HDcalloc(2, 10);
+ buf = (char*)HDcalloc(2, 10);
HDmemcpy(buf, "abcdefghijabcdefghij", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (HDmemcmp(buf, "abcdefghijabcdefghij", 20)) {
@@ -3621,7 +3653,7 @@ test_conv_str_1(void)
*/
src_type = mkstr(10, H5T_STR_NULLTERM);
dst_type = mkstr(10, H5T_STR_SPACEPAD);
- buf = HDcalloc(2, 10);
+ buf = (char*)HDcalloc(2, 10);
HDmemcpy(buf, "abcdefghi\0abcdefghi\0", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (HDmemcmp(buf, "abcdefghi abcdefghi ", 20)) {
@@ -3676,7 +3708,7 @@ test_conv_str_1(void)
*/
src_type = mkstr(10, H5T_STR_NULLPAD);
dst_type = mkstr(10, H5T_STR_SPACEPAD);
- buf = HDcalloc(2, 10);
+ buf = (char*)HDcalloc(2, 10);
HDmemcpy(buf, "abcdefghijabcdefghij", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error;
if (HDmemcmp(buf, "abcdefghijabcdefghij", 20)) {
@@ -3766,7 +3798,7 @@ test_conv_str_2(void)
*/
c_type = mkstr(8, H5T_STR_NULLPAD);
f_type = mkstr(8, H5T_STR_SPACEPAD);
- buf = HDcalloc(nelmts, 8);
+ buf = (char*)HDcalloc(nelmts, 8);
for (i=0; i<nelmts; i++) {
nchars = HDrand() % 8;
for (j=0; j<nchars; j++)
@@ -3837,7 +3869,7 @@ test_conv_enum_1(void)
}
/* Initialize the buffer */
- buf = HDmalloc(nelmts*MAX(H5Tget_size(t1), H5Tget_size(t2)));
+ buf = (int*)HDmalloc(nelmts*MAX(H5Tget_size(t1), H5Tget_size(t2)));
for (i=0; i<(int)nelmts; i++)
buf[i] = HDrand() % 26;
@@ -3926,7 +3958,7 @@ test_conv_enum_2(void)
H5Tenum_insert(dsttype, mname[i], &i);
/* Source data */
- data = malloc(NTESTELEM*sizeof(int));
+ data = (int*)malloc(NTESTELEM*sizeof(int));
for (i=0; i<NTESTELEM; i++) {
((char*)data)[i*3+2] = i % 8;
((char*)data)[i*3+0] = 0;