diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5D.c | 21 | ||||
-rw-r--r-- | src/H5Distore.c | 4 | ||||
-rw-r--r-- | src/H5F.c | 9 | ||||
-rw-r--r-- | src/H5FDmulti.c | 10 | ||||
-rw-r--r-- | src/H5Farray.c | 6 | ||||
-rw-r--r-- | src/H5Fistore.c | 4 | ||||
-rw-r--r-- | src/H5Fprivate.h | 2 | ||||
-rw-r--r-- | src/H5Odtype.c | 1001 | ||||
-rw-r--r-- | src/H5S.c | 2 | ||||
-rw-r--r-- | src/H5Sall.c | 4 | ||||
-rw-r--r-- | src/H5Spoint.c | 2 | ||||
-rw-r--r-- | src/H5T.c | 156 | ||||
-rw-r--r-- | src/H5Tconv.c | 3 | ||||
-rw-r--r-- | src/H5Tpkg.h | 14 | ||||
-rw-r--r-- | src/H5Tprivate.h | 18 | ||||
-rw-r--r-- | src/H5Tpublic.h | 3 | ||||
-rw-r--r-- | src/H5Tvlen.c | 192 | ||||
-rw-r--r-- | src/H5config.h.in | 3 |
18 files changed, 824 insertions, 630 deletions
@@ -1890,6 +1890,9 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, HDmemset(&mem_iter,0,sizeof(H5S_sel_iter_t)); HDmemset(&bkg_iter,0,sizeof(H5S_sel_iter_t)); HDmemset(&file_iter,0,sizeof(H5S_sel_iter_t)); +#ifdef QAK + printf("%s: check 0.3, buf=%p\n", FUNC,buf); +#endif /* QAK */ /* Get the dataset transfer property list */ if (H5P_DEFAULT == dxpl_id) { @@ -2129,7 +2132,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, printf("\n"); } } - printf("%s: check 6.0\n",FUNC); + printf("%s: check 6.0, tconv_buf=%p, *tconv_buf=%p\n",FUNC,tconv_buf,*(char **)tconv_buf); #endif if (H5T_BKG_YES==need_bkg) { @@ -2807,11 +2810,11 @@ H5D_vlen_get_buf_size(void UNUSED *elem, hid_t type_id, hsize_t UNUSED ndim, hss HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't resize tbuf"); /* Select point to read in */ - if (H5Sselect_elements(vlen_bufsize->space_id,H5S_SELECT_SET,1,(const hssize_t **)point)<0) + if (H5Sselect_elements(vlen_bufsize->fspace_id,H5S_SELECT_SET,1,(const hssize_t **)point)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't select point"); /* Read in the point (with the custom VL memory allocator) */ - if(H5Dread(vlen_bufsize->dataset_id,type_id,H5S_ALL,vlen_bufsize->space_id,vlen_bufsize->xfer_pid,tbuf)<0) + if(H5Dread(vlen_bufsize->dataset_id,type_id,vlen_bufsize->mspace_id,vlen_bufsize->fspace_id,vlen_bufsize->xfer_pid,tbuf)<0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point"); /* Set the correct return value, if we get this far */ @@ -2871,8 +2874,12 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, vlen_bufsize.dataset_id=dataset_id; /* Get a copy of the dataspace ID */ - if((vlen_bufsize.space_id=H5Dget_space(dataset_id))<0) + if((vlen_bufsize.fspace_id=H5Dget_space(dataset_id))<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy dataspace"); + + /* Create a scalar for the memory dataspace */ + if((vlen_bufsize.mspace_id=H5Screate(H5S_SCALAR))<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't create dataspace"); /* Grab the temporary buffers required */ if((vlen_bufsize.fl_tbuf_id=H5TB_get_buf(1,0,NULL))<0) @@ -2899,8 +2906,10 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, *size=vlen_bufsize.size; done: - if(vlen_bufsize.space_id>0) - H5Sclose(vlen_bufsize.space_id); + if(vlen_bufsize.fspace_id>0) + H5Sclose(vlen_bufsize.fspace_id); + if(vlen_bufsize.mspace_id>0) + H5Sclose(vlen_bufsize.mspace_id); if(vlen_bufsize.fl_tbuf_id>0) H5TB_release_buf(vlen_bufsize.fl_tbuf_id); if(vlen_bufsize.vl_tbuf_id>0) diff --git a/src/H5Distore.c b/src/H5Distore.c index e3a0d49..44b0ce3 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -1402,7 +1402,7 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, { H5F_xfer_t *dxpl; - dxpl = (H5P_DEFAULT==dxpl_id)?&H5F_xfer_dflt:H5I_object(dxpl_id); + dxpl = (H5P_DEFAULT==dxpl_id) ? &H5F_xfer_dflt : H5I_object(dxpl_id); ent->split_ratios[0] = dxpl->split_ratios[0]; ent->split_ratios[1] = dxpl->split_ratios[1]; ent->split_ratios[2] = dxpl->split_ratios[2]; @@ -1544,7 +1544,7 @@ H5F_istore_unlock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, x.chunk = chunk; { H5F_xfer_t *dxpl; - dxpl = (H5P_DEFAULT==dxpl_id)?&H5F_xfer_dflt:H5I_object(dxpl_id); + dxpl = (H5P_DEFAULT==dxpl_id) ? &H5F_xfer_dflt : H5I_object(dxpl_id); x.split_ratios[0] = dxpl->split_ratios[0]; x.split_ratios[1] = dxpl->split_ratios[1]; x.split_ratios[2] = dxpl->split_ratios[2]; @@ -75,7 +75,8 @@ const H5F_create_t H5F_create_dflt = { H5F_access_t H5F_access_dflt; /* Default data transfer property list */ -const H5F_xfer_t H5F_xfer_dflt = { +/* Not const anymore before some of the VFL drivers modify this struct - QAK */ +H5F_xfer_t H5F_xfer_dflt = { 1024*1024, /*Temporary buffer size */ NULL, /*Type conversion buffer or NULL */ NULL, /*Background buffer or NULL */ @@ -629,7 +630,7 @@ htri_t H5Fis_hdf5(const char *name) { H5FD_t *file = NULL; - hbool_t ret_value = FAIL; + htri_t ret_value = FAIL; FUNC_ENTER(H5Fis_hdf5, FAIL); H5TRACE1("b","s",name); @@ -1081,7 +1082,7 @@ H5F_open(const char *name, uintn flags, hid_t fcpl_id, hid_t fapl_id) } if (H5FD_set_eoa(lf, shared->boot_addr+fixed_size)<0 || H5FD_read(lf, H5P_DEFAULT, shared->boot_addr, fixed_size, buf)<0) { - HGOTO_ERROR(H5E_FILE, H5E_IO, NULL, + HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock"); } @@ -1206,7 +1207,7 @@ H5F_open(const char *name, uintn flags, hid_t fcpl_id, hid_t fapl_id) UINT32DECODE(p, driver_size); /* Driver name and/or version */ - strncpy(driver_name, p, 8); + strncpy(driver_name, (const char *)p, 8); driver_name[8] = '\0'; /* Read driver information and decode */ diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 004e07e..b484812 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -27,8 +27,12 @@ #undef MIN #define MIN(X,Y) ((X)<(Y)?(X):(Y)) +#ifndef FALSE #define FALSE 0 +#endif +#ifndef TRUE #define TRUE 1 +#endif /* Loop through all mapped files */ #define UNIQUE_MEMBERS(MAP,LOOPVAR) { \ @@ -679,7 +683,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, p = buf + 8 + nseen*2*8; UNIQUE_MEMBERS(file->fa.memb_map, mt) { size_t n = strlen(file->fa.memb_name[mt]) + 1; - strcpy(p, file->fa.memb_name[mt]); + strcpy((char *)p, file->fa.memb_name[mt]); p += n; for (i=n; i%8; i++) *p++ = '\0'; } END_MEMBERS; @@ -761,8 +765,8 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) /* Decode name templates */ UNIQUE_MEMBERS(map, mt) { - size_t n = strlen(buf)+1; - memb_name[_unmapped] = buf; + size_t n = strlen((char *)buf)+1; + memb_name[_unmapped] = (char *)buf; buf += (n+7) & ~0x0007; } END_MEMBERS; diff --git a/src/H5Farray.c b/src/H5Farray.c index 6019f1e..ecf6066 100644 --- a/src/H5Farray.c +++ b/src/H5Farray.c @@ -183,10 +183,10 @@ H5F_arr_read(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, { extern int qak_debug; - printf("%s: layout->ndims=%d\n",FUNC,(int)layout->ndims); - for(i=0; i<layout->ndims; i++) - printf("%s: %d: hslab_size=%d, mem_size=%d, mem_offset=%d, file_offset=%d\n",FUNC,i,(int)_hslab_size[i],(int)mem_size[i],(int)mem_offset[i],(int)file_offset[i]); if(qak_debug) { + printf("%s: layout->ndims=%d\n",FUNC,(int)layout->ndims); + for(i=0; i<layout->ndims; i++) + printf("%s: %d: hslab_size=%d, mem_size=%d, mem_offset=%d, file_offset=%d\n",FUNC,i,(int)_hslab_size[i],(int)mem_size[i],(int)mem_offset[i],(int)file_offset[i]); printf("%s: *buf=%d, *(buf+1)=%d\n", FUNC,(int)*(const uint16_t *)buf,(int)*((const uint16 *)buf+1)); } } diff --git a/src/H5Fistore.c b/src/H5Fistore.c index e3a0d49..44b0ce3 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -1402,7 +1402,7 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, { H5F_xfer_t *dxpl; - dxpl = (H5P_DEFAULT==dxpl_id)?&H5F_xfer_dflt:H5I_object(dxpl_id); + dxpl = (H5P_DEFAULT==dxpl_id) ? &H5F_xfer_dflt : H5I_object(dxpl_id); ent->split_ratios[0] = dxpl->split_ratios[0]; ent->split_ratios[1] = dxpl->split_ratios[1]; ent->split_ratios[2] = dxpl->split_ratios[2]; @@ -1544,7 +1544,7 @@ H5F_istore_unlock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, x.chunk = chunk; { H5F_xfer_t *dxpl; - dxpl = (H5P_DEFAULT==dxpl_id)?&H5F_xfer_dflt:H5I_object(dxpl_id); + dxpl = (H5P_DEFAULT==dxpl_id) ? &H5F_xfer_dflt : H5I_object(dxpl_id); x.split_ratios[0] = dxpl->split_ratios[0]; x.split_ratios[1] = dxpl->split_ratios[1]; x.split_ratios[2] = dxpl->split_ratios[2]; diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 0c2360f..7ee6085 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -412,7 +412,7 @@ struct H5G_entry_t; /* library variables */ __DLLVAR__ const H5F_create_t H5F_create_dflt; __DLLVAR__ H5F_access_t H5F_access_dflt; -__DLLVAR__ const H5F_xfer_t H5F_xfer_dflt; +__DLLVAR__ H5F_xfer_t H5F_xfer_dflt; __DLLVAR__ const H5F_mprop_t H5F_mount_dflt; #ifdef HAVE_PARALLEL diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 214782c..569c635 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -101,220 +101,223 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt) UINT32DECODE(*pp, dt->size); switch (dt->type) { - case H5T_INTEGER: - /* - * Integer types... - */ - dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; - dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; - dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; - dt->u.atomic.u.i.sign = (flags & 0x8) ? H5T_SGN_2 : H5T_SGN_NONE; - UINT16DECODE(*pp, dt->u.atomic.offset); - UINT16DECODE(*pp, dt->u.atomic.prec); - break; - - case H5T_BITFIELD: - /* - * Bit fields... - */ - dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; - dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; - dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; - UINT16DECODE(*pp, dt->u.atomic.offset); - UINT16DECODE(*pp, dt->u.atomic.prec); - break; - - case H5T_OPAQUE: - /* - * Opaque types... - */ - z = flags & 0xff; - assert(0==(z&0x7)); /*must be aligned*/ - if (NULL==(dt->u.opaque.tag=H5MM_malloc(z+1))) { - HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed"); - } - HDmemcpy(dt->u.opaque.tag, *pp, z); - dt->u.opaque.tag[z] = '\0'; - *pp += z; - break; - - case H5T_STRING: - /* - * Character string types... - */ - dt->u.atomic.order = H5T_ORDER_NONE; - dt->u.atomic.prec = 8 * dt->size; - dt->u.atomic.offset = 0; - dt->u.atomic.lsb_pad = H5T_PAD_ZERO; - dt->u.atomic.msb_pad = H5T_PAD_ZERO; - - dt->u.atomic.u.s.pad = (H5T_str_t)(flags & 0x0f); - dt->u.atomic.u.s.cset = (H5T_cset_t)((flags>>4) & 0x0f); - break; - - case H5T_FLOAT: - /* - * Floating-point types... - */ - dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; - dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; - dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; - dt->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO; - switch ((flags >> 4) & 0x03) { - case 0: - dt->u.atomic.u.f.norm = H5T_NORM_NONE; - break; - case 1: - dt->u.atomic.u.f.norm = H5T_NORM_MSBSET; - break; - case 2: - dt->u.atomic.u.f.norm = H5T_NORM_IMPLIED; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "unknown floating-point normalization"); - } - dt->u.atomic.u.f.sign = (flags >> 8) & 0xff; - UINT16DECODE(*pp, dt->u.atomic.offset); - UINT16DECODE(*pp, dt->u.atomic.prec); - dt->u.atomic.u.f.epos = *(*pp)++; - dt->u.atomic.u.f.esize = *(*pp)++; - assert(dt->u.atomic.u.f.esize > 0); - dt->u.atomic.u.f.mpos = *(*pp)++; - dt->u.atomic.u.f.msize = *(*pp)++; - assert(dt->u.atomic.u.f.msize > 0); - UINT32DECODE(*pp, dt->u.atomic.u.f.ebias); - break; - - case H5T_COMPOUND: - /* - * Compound data types... - */ - dt->u.compnd.nmembs = flags & 0xffff; - assert(dt->u.compnd.nmembs > 0); - dt->u.compnd.nalloc = dt->u.compnd.nmembs; - dt->u.compnd.memb = H5MM_calloc(dt->u.compnd.nalloc* - sizeof(H5T_cmemb_t)); - if (NULL==dt->u.compnd.memb) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed"); - } - for (i = 0; i < dt->u.compnd.nmembs; i++) { - dt->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp); - /*multiple of 8 w/ null terminator */ - *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8; - UINT32DECODE(*pp, dt->u.compnd.memb[i].offset); - dt->u.compnd.memb[i].ndims = *(*pp)++; - assert(dt->u.compnd.memb[i].ndims <= 4); - *pp += 3; /*reserved bytes */ - - /* Dimension permutation */ - UINT32DECODE(*pp, perm_word); - dt->u.compnd.memb[i].perm[0] = (perm_word >> 0) & 0xff; - dt->u.compnd.memb[i].perm[1] = (perm_word >> 8) & 0xff; - dt->u.compnd.memb[i].perm[2] = (perm_word >> 16) & 0xff; - dt->u.compnd.memb[i].perm[3] = (perm_word >> 24) & 0xff; - dt->u.compnd.memb[i].type = H5MM_calloc (sizeof(H5T_t)); - - /* Reserved */ - *pp += 4; - - /* Dimension sizes */ - for (j=0; j<4; j++) { - UINT32DECODE(*pp, dt->u.compnd.memb[i].dim[j]); - } - if (NULL==dt->u.compnd.memb[i].type) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed"); - } - dt->u.compnd.memb[i].type->ent.header = HADDR_UNDEF; - if (H5O_dtype_decode_helper(f, pp, dt->u.compnd.memb[i].type)<0) { - for (j=0; j<=i; j++) H5MM_xfree(dt->u.compnd.memb[j].name); - H5MM_xfree(dt->u.compnd.memb); - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, - "unable to decode member type"); - } + case H5T_INTEGER: + /* + * Integer types... + */ + dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->u.atomic.u.i.sign = (flags & 0x8) ? H5T_SGN_2 : H5T_SGN_NONE; + UINT16DECODE(*pp, dt->u.atomic.offset); + UINT16DECODE(*pp, dt->u.atomic.prec); + break; + + case H5T_BITFIELD: + /* + * Bit fields... + */ + dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; + UINT16DECODE(*pp, dt->u.atomic.offset); + UINT16DECODE(*pp, dt->u.atomic.prec); + break; + + case H5T_OPAQUE: + /* + * Opaque types... + */ + z = flags & 0xff; + assert(0==(z&0x7)); /*must be aligned*/ + if (NULL==(dt->u.opaque.tag=H5MM_malloc(z+1))) { + HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed"); + } + HDmemcpy(dt->u.opaque.tag, *pp, z); + dt->u.opaque.tag[z] = '\0'; + *pp += z; + break; + + case H5T_FLOAT: + /* + * Floating-point types... + */ + dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; + dt->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO; + switch ((flags >> 4) & 0x03) { + case 0: + dt->u.atomic.u.f.norm = H5T_NORM_NONE; + break; + case 1: + dt->u.atomic.u.f.norm = H5T_NORM_MSBSET; + break; + case 2: + dt->u.atomic.u.f.norm = H5T_NORM_IMPLIED; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "unknown floating-point normalization"); + } + dt->u.atomic.u.f.sign = (flags >> 8) & 0xff; + UINT16DECODE(*pp, dt->u.atomic.offset); + UINT16DECODE(*pp, dt->u.atomic.prec); + dt->u.atomic.u.f.epos = *(*pp)++; + dt->u.atomic.u.f.esize = *(*pp)++; + assert(dt->u.atomic.u.f.esize > 0); + dt->u.atomic.u.f.mpos = *(*pp)++; + dt->u.atomic.u.f.msize = *(*pp)++; + assert(dt->u.atomic.u.f.msize > 0); + UINT32DECODE(*pp, dt->u.atomic.u.f.ebias); + break; + + case H5T_COMPOUND: + /* + * Compound data types... + */ + dt->u.compnd.nmembs = flags & 0xffff; + assert(dt->u.compnd.nmembs > 0); + dt->u.compnd.nalloc = dt->u.compnd.nmembs; + dt->u.compnd.memb = H5MM_calloc(dt->u.compnd.nalloc* + sizeof(H5T_cmemb_t)); + if (NULL==dt->u.compnd.memb) { + HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed"); + } + for (i = 0; i < dt->u.compnd.nmembs; i++) { + dt->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp); + /*multiple of 8 w/ null terminator */ + *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8; + UINT32DECODE(*pp, dt->u.compnd.memb[i].offset); + dt->u.compnd.memb[i].ndims = *(*pp)++; + assert(dt->u.compnd.memb[i].ndims <= 4); + *pp += 3; /*reserved bytes */ + + /* Dimension permutation */ + UINT32DECODE(*pp, perm_word); + dt->u.compnd.memb[i].perm[0] = (perm_word >> 0) & 0xff; + dt->u.compnd.memb[i].perm[1] = (perm_word >> 8) & 0xff; + dt->u.compnd.memb[i].perm[2] = (perm_word >> 16) & 0xff; + dt->u.compnd.memb[i].perm[3] = (perm_word >> 24) & 0xff; + dt->u.compnd.memb[i].type = H5MM_calloc (sizeof(H5T_t)); + + /* Reserved */ + *pp += 4; + + /* Dimension sizes */ + for (j=0; j<4; j++) { + UINT32DECODE(*pp, dt->u.compnd.memb[i].dim[j]); + } + if (NULL==dt->u.compnd.memb[i].type) { + HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed"); + } + dt->u.compnd.memb[i].type->ent.header = HADDR_UNDEF; + if (H5O_dtype_decode_helper(f, pp, dt->u.compnd.memb[i].type)<0) { + for (j=0; j<=i; j++) H5MM_xfree(dt->u.compnd.memb[j].name); + H5MM_xfree(dt->u.compnd.memb); + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, + "unable to decode member type"); + } + + /* + * Set the "force conversion" flag if VL datatype fields exist in this + * type or any component types + */ + if(dt->u.compnd.memb[i].type->type==H5T_VLEN || dt->u.compnd.memb[i].type->force_conv==TRUE) + dt->force_conv=TRUE; + + /* Total member size */ + dt->u.compnd.memb[i].size = dt->u.compnd.memb[i].type->size; + for (j=0; j<dt->u.compnd.memb[i].ndims; j++) { + dt->u.compnd.memb[i].size *= dt->u.compnd.memb[i].dim[j]; + } + } + break; + + case H5T_ENUM: + /* + * Enumeration data types... + */ + dt->u.enumer.nmembs = dt->u.enumer.nalloc = flags & 0xffff; + assert(dt->u.enumer.nmembs>=0); + if (NULL==(dt->parent=H5MM_calloc(sizeof(H5T_t)))) { + HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed"); + } + dt->parent->ent.header = HADDR_UNDEF; + if (H5O_dtype_decode_helper(f, pp, dt->parent)<0) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, + "unable to decode parent data type"); + } + if (NULL==(dt->u.enumer.name=H5MM_calloc(dt->u.enumer.nalloc * + sizeof(char*))) || + NULL==(dt->u.enumer.value=H5MM_calloc(dt->u.enumer.nalloc * + dt->parent->size))) { + HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed"); + } + + /* Names, each a multiple of 8 with null termination */ + for (i=0; i<dt->u.enumer.nmembs; i++) { + dt->u.enumer.name[i] = H5MM_xstrdup((const char*)*pp); + *pp += ((HDstrlen((const char*)*pp)+8)/8)*8; + } + + /* Values */ + HDmemcpy(dt->u.enumer.value, *pp, + dt->u.enumer.nmembs * dt->parent->size); + *pp += dt->u.enumer.nmembs * dt->parent->size; + break; + + case H5T_REFERENCE: /* Reference data types... */ + dt->u.atomic.order = H5T_ORDER_NONE; + dt->u.atomic.prec = 8 * dt->size; + dt->u.atomic.offset = 0; + dt->u.atomic.lsb_pad = H5T_PAD_ZERO; + dt->u.atomic.msb_pad = H5T_PAD_ZERO; + dt->u.atomic.u.r.rtype = (H5R_type_t)(flags & 0x0f); + break; + + case H5T_STRING: + /* + * Character string types... + */ + dt->u.atomic.order = H5T_ORDER_NONE; + dt->u.atomic.prec = 8 * dt->size; + dt->u.atomic.offset = 0; + dt->u.atomic.lsb_pad = H5T_PAD_ZERO; + dt->u.atomic.msb_pad = H5T_PAD_ZERO; + + dt->u.atomic.u.s.pad = (H5T_str_t)(flags & 0x0f); + dt->u.atomic.u.s.cset = (H5T_cset_t)((flags>>4) & 0x0f); + break; + + case H5T_VLEN: /* Variable length datatypes... */ + /* Set the type of VL information, either sequence or string */ + dt->u.vlen.type = (H5T_vlen_type_t)(flags & 0x0f); + + /* Decode base type of VL information */ + dt->parent->ent.header = HADDR_UNDEF; + if (H5O_dtype_decode_helper(f, pp, dt->parent)<0) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type"); + } - /* - * Set the "force conversion" flag if VL datatype fields exist in this - * type or any component types - */ - if(dt->u.compnd.memb[i].type->type==H5T_VLEN || dt->u.compnd.memb[i].type->force_conv==TRUE) dt->force_conv=TRUE; - - /* Total member size */ - dt->u.compnd.memb[i].size = dt->u.compnd.memb[i].type->size; - for (j=0; j<dt->u.compnd.memb[i].ndims; j++) { - dt->u.compnd.memb[i].size *= dt->u.compnd.memb[i].dim[j]; - } - } - break; - - case H5T_ENUM: - /* - * Enumeration data types... - */ - dt->u.enumer.nmembs = dt->u.enumer.nalloc = flags & 0xffff; - assert(dt->u.enumer.nmembs>=0); - if (NULL==(dt->parent=H5MM_calloc(sizeof(H5T_t)))) { - HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed"); - } - dt->parent->ent.header = HADDR_UNDEF; - if (H5O_dtype_decode_helper(f, pp, dt->parent)<0) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, - "unable to decode parent data type"); - } - if (NULL==(dt->u.enumer.name=H5MM_calloc(dt->u.enumer.nalloc * - sizeof(char*))) || - NULL==(dt->u.enumer.value=H5MM_calloc(dt->u.enumer.nalloc * - dt->parent->size))) { - HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed"); - } - - /* Names, each a multiple of 8 with null termination */ - for (i=0; i<dt->u.enumer.nmembs; i++) { - dt->u.enumer.name[i] = H5MM_xstrdup((const char*)*pp); - *pp += ((HDstrlen((const char*)*pp)+8)/8)*8; - } - - /* Values */ - HDmemcpy(dt->u.enumer.value, *pp, - dt->u.enumer.nmembs * dt->parent->size); - *pp += dt->u.enumer.nmembs * dt->parent->size; - break; - - case H5T_REFERENCE: - dt->u.atomic.order = H5T_ORDER_NONE; - dt->u.atomic.prec = 8 * dt->size; - dt->u.atomic.offset = 0; - dt->u.atomic.lsb_pad = H5T_PAD_ZERO; - dt->u.atomic.msb_pad = H5T_PAD_ZERO; - dt->u.atomic.u.r.rtype = (H5R_type_t)(flags & 0x0f); - break; - - case H5T_VLEN: /* Variable length datatypes... */ - /* Decode base type of VL information */ - dt->parent->ent.header = HADDR_UNDEF; - if (H5O_dtype_decode_helper(f, pp, dt->parent)<0) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type"); - } - - dt->force_conv=TRUE; - /* Mark this type as on disk */ - if (H5T_vlen_mark(dt, f, H5T_VLEN_DISK)<0) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); - } - break; - - default: - if (flags) { - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "class flags are non-zero"); - } - break; + /* Mark this type as on disk */ + if (H5T_vlen_mark(dt, f, H5T_VLEN_DISK)<0) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); + } + break; + + default: + if (flags) { + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "class flags are non-zero"); + } + break; } FUNC_LEAVE(SUCCEED); @@ -356,292 +359,296 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt) UINT32ENCODE(*pp, dt->size); switch (dt->type) { - case H5T_INTEGER: - /* - * Integer data types... - */ - switch (dt->u.atomic.order) { - case H5T_ORDER_LE: - break; /*nothing */ - case H5T_ORDER_BE: - flags |= 0x01; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "byte order is not supported in file format yet"); - } - - switch (dt->u.atomic.lsb_pad) { - case H5T_PAD_ZERO: - break; /*nothing */ - case H5T_PAD_ONE: - flags |= 0x02; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "bit padding is not supported in file format yet"); - } - - switch (dt->u.atomic.msb_pad) { - case H5T_PAD_ZERO: - break; /*nothing */ - case H5T_PAD_ONE: - flags |= 0x04; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "bit padding is not supported in file format yet"); - } - - switch (dt->u.atomic.u.i.sign) { - case H5T_SGN_NONE: - break; /*nothing */ - case H5T_SGN_2: - flags |= 0x08; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "sign scheme is not supported in file format yet"); - } - - UINT16ENCODE(*pp, dt->u.atomic.offset); - UINT16ENCODE(*pp, dt->u.atomic.prec); - break; - - case H5T_BITFIELD: - /* - * Bitfield data types... - */ - switch (dt->u.atomic.order) { - case H5T_ORDER_LE: - break; /*nothing */ - case H5T_ORDER_BE: - flags |= 0x01; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "byte order is not supported in file format yet"); - } - - switch (dt->u.atomic.lsb_pad) { - case H5T_PAD_ZERO: - break; /*nothing */ - case H5T_PAD_ONE: - flags |= 0x02; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "bit padding is not supported in file format yet"); - } - - switch (dt->u.atomic.msb_pad) { - case H5T_PAD_ZERO: - break; /*nothing */ - case H5T_PAD_ONE: - flags |= 0x04; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "bit padding is not supported in file format yet"); - } - - UINT16ENCODE(*pp, dt->u.atomic.offset); - UINT16ENCODE(*pp, dt->u.atomic.prec); - break; - - case H5T_OPAQUE: - /* - * Opaque data types... The tag is stored in a field which is a - * multiple of eight characters and null padded (not necessarily - * null terminated). - */ - z = HDstrlen(dt->u.opaque.tag); - aligned = (z+7) & 0xf8; - flags |= aligned; - HDmemcpy(*pp, dt->u.opaque.tag, MIN(z,aligned)); - for (n=MIN(z,aligned); n<aligned; n++) (*pp)[n] = 0; - *pp += aligned; - break; - - case H5T_STRING: - /* - * Character string types... (not fully implemented) - */ - assert (dt->u.atomic.order == H5T_ORDER_NONE); - assert (dt->u.atomic.prec == 8 * dt->size); - assert (dt->u.atomic.offset == 0); - assert (dt->u.atomic.lsb_pad == H5T_PAD_ZERO); - assert (dt->u.atomic.msb_pad == H5T_PAD_ZERO); - - flags |= (dt->u.atomic.u.s.pad & 0x0f); - flags |= (dt->u.atomic.u.s.cset & 0x0f) << 4; - break; - - case H5T_FLOAT: - /* - * Floating-point types... - */ - switch (dt->u.atomic.order) { - case H5T_ORDER_LE: - break; /*nothing */ - case H5T_ORDER_BE: - flags |= 0x01; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "byte order is not supported in file format yet"); - } - - switch (dt->u.atomic.lsb_pad) { - case H5T_PAD_ZERO: - break; /*nothing */ - case H5T_PAD_ONE: - flags |= 0x02; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "bit padding is not supported in file format yet"); - } - - switch (dt->u.atomic.msb_pad) { - case H5T_PAD_ZERO: - break; /*nothing */ - case H5T_PAD_ONE: - flags |= 0x04; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "bit padding is not supported in file format yet"); - } - - switch (dt->u.atomic.u.f.pad) { - case H5T_PAD_ZERO: - break; /*nothing */ - case H5T_PAD_ONE: - flags |= 0x08; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "bit padding is not supported in file format yet"); - } - - switch (dt->u.atomic.u.f.norm) { - case H5T_NORM_NONE: - break; /*nothing */ - case H5T_NORM_MSBSET: - flags |= 0x10; - break; - case H5T_NORM_IMPLIED: - flags |= 0x20; - break; - default: - HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "normalization scheme is not supported in file " - "format yet"); - } - - flags |= (dt->u.atomic.u.f.sign << 8) & 0xff00; - UINT16ENCODE(*pp, dt->u.atomic.offset); - UINT16ENCODE(*pp, dt->u.atomic.prec); - assert (dt->u.atomic.u.f.epos<=255); - *(*pp)++ = (uint8_t)(dt->u.atomic.u.f.epos); - assert (dt->u.atomic.u.f.esize<=255); - *(*pp)++ = (uint8_t)(dt->u.atomic.u.f.esize); - assert (dt->u.atomic.u.f.mpos<=255); - *(*pp)++ = (uint8_t)(dt->u.atomic.u.f.mpos); - assert (dt->u.atomic.u.f.msize<=255); - *(*pp)++ = (uint8_t)(dt->u.atomic.u.f.msize); - UINT32ENCODE(*pp, dt->u.atomic.u.f.ebias); - break; - - case H5T_COMPOUND: - /* - * Compound data types... - */ - flags = dt->u.compnd.nmembs & 0xffff; - for (i=0; i<dt->u.compnd.nmembs; i++) { - /* Name, multiple of eight bytes */ - HDstrcpy((char*)(*pp), dt->u.compnd.memb[i].name); - n = HDstrlen(dt->u.compnd.memb[i].name); - for (z=n+1; z%8; z++) (*pp)[z] = '\0'; - *pp += z; - - /* Member offset */ - UINT32ENCODE(*pp, dt->u.compnd.memb[i].offset); - - /* Dimensionality */ - *(*pp)++ = dt->u.compnd.memb[i].ndims; - assert(dt->u.compnd.memb[i].ndims <= 4); - - /* Reserved */ - *(*pp)++ = '\0'; - *(*pp)++ = '\0'; - *(*pp)++ = '\0'; - - /* Dimension permutation */ - for (j = 0, perm_word = 0; j < dt->u.compnd.memb[i].ndims; j++) { - perm_word |= dt->u.compnd.memb[i].perm[j] << (8 * j); - } - UINT32ENCODE(*pp, perm_word); - - /* Reserved */ - UINT32ENCODE(*pp, 0); - - /* Dimensions */ - for (j=0; j<dt->u.compnd.memb[i].ndims; j++) { - UINT32ENCODE(*pp, dt->u.compnd.memb[i].dim[j]); - } - for (/*void*/; j<4; j++) { - UINT32ENCODE(*pp, 0); - } - - /* Subtype */ - if (H5O_dtype_encode_helper(pp, dt->u.compnd.memb[i].type)<0) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, - "unable to encode member type"); - } - } - break; - - case H5T_ENUM: - /* - * Enumeration data types... - */ - flags = dt->u.enumer.nmembs & 0xffff; - - /* Parent type */ - if (H5O_dtype_encode_helper(pp, dt->parent)<0) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, - "unable to encode parent data type"); - } - - /* Names, each a multiple of eight bytes */ - for (i=0; i<dt->u.enumer.nmembs; i++) { - HDstrcpy((char*)(*pp), dt->u.enumer.name[i]); - n = HDstrlen(dt->u.enumer.name[i]); - for (z=n+1; z%8; z++) (*pp)[z] = '\0'; - *pp += z; - } - - /* Values */ - HDmemcpy(*pp, dt->u.enumer.value, dt->u.enumer.nmembs * dt->parent->size); - *pp += dt->u.enumer.nmembs * dt->parent->size; - break; - - case H5T_REFERENCE: - flags |= (dt->u.atomic.u.r.rtype & 0x0f); - break; + case H5T_INTEGER: + /* + * Integer data types... + */ + switch (dt->u.atomic.order) { + case H5T_ORDER_LE: + break; /*nothing */ + case H5T_ORDER_BE: + flags |= 0x01; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "byte order is not supported in file format yet"); + } + + switch (dt->u.atomic.lsb_pad) { + case H5T_PAD_ZERO: + break; /*nothing */ + case H5T_PAD_ONE: + flags |= 0x02; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet"); + } + + switch (dt->u.atomic.msb_pad) { + case H5T_PAD_ZERO: + break; /*nothing */ + case H5T_PAD_ONE: + flags |= 0x04; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet"); + } + + switch (dt->u.atomic.u.i.sign) { + case H5T_SGN_NONE: + break; /*nothing */ + case H5T_SGN_2: + flags |= 0x08; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "sign scheme is not supported in file format yet"); + } + + UINT16ENCODE(*pp, dt->u.atomic.offset); + UINT16ENCODE(*pp, dt->u.atomic.prec); + break; + + case H5T_BITFIELD: + /* + * Bitfield data types... + */ + switch (dt->u.atomic.order) { + case H5T_ORDER_LE: + break; /*nothing */ + case H5T_ORDER_BE: + flags |= 0x01; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "byte order is not supported in file format yet"); + } + + switch (dt->u.atomic.lsb_pad) { + case H5T_PAD_ZERO: + break; /*nothing */ + case H5T_PAD_ONE: + flags |= 0x02; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet"); + } + + switch (dt->u.atomic.msb_pad) { + case H5T_PAD_ZERO: + break; /*nothing */ + case H5T_PAD_ONE: + flags |= 0x04; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet"); + } + + UINT16ENCODE(*pp, dt->u.atomic.offset); + UINT16ENCODE(*pp, dt->u.atomic.prec); + break; + + case H5T_OPAQUE: + /* + * Opaque data types... The tag is stored in a field which is a + * multiple of eight characters and null padded (not necessarily + * null terminated). + */ + z = HDstrlen(dt->u.opaque.tag); + aligned = (z+7) & 0xf8; + flags |= aligned; + HDmemcpy(*pp, dt->u.opaque.tag, MIN(z,aligned)); + for (n=MIN(z,aligned); n<aligned; n++) (*pp)[n] = 0; + *pp += aligned; + break; + + case H5T_FLOAT: + /* + * Floating-point types... + */ + switch (dt->u.atomic.order) { + case H5T_ORDER_LE: + break; /*nothing */ + case H5T_ORDER_BE: + flags |= 0x01; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "byte order is not supported in file format yet"); + } + + switch (dt->u.atomic.lsb_pad) { + case H5T_PAD_ZERO: + break; /*nothing */ + case H5T_PAD_ONE: + flags |= 0x02; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet"); + } + + switch (dt->u.atomic.msb_pad) { + case H5T_PAD_ZERO: + break; /*nothing */ + case H5T_PAD_ONE: + flags |= 0x04; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet"); + } + + switch (dt->u.atomic.u.f.pad) { + case H5T_PAD_ZERO: + break; /*nothing */ + case H5T_PAD_ONE: + flags |= 0x08; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "bit padding is not supported in file format yet"); + } + + switch (dt->u.atomic.u.f.norm) { + case H5T_NORM_NONE: + break; /*nothing */ + case H5T_NORM_MSBSET: + flags |= 0x10; + break; + case H5T_NORM_IMPLIED: + flags |= 0x20; + break; + default: + HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "normalization scheme is not supported in file format yet"); + } + + flags |= (dt->u.atomic.u.f.sign << 8) & 0xff00; + UINT16ENCODE(*pp, dt->u.atomic.offset); + UINT16ENCODE(*pp, dt->u.atomic.prec); + assert (dt->u.atomic.u.f.epos<=255); + *(*pp)++ = (uint8_t)(dt->u.atomic.u.f.epos); + assert (dt->u.atomic.u.f.esize<=255); + *(*pp)++ = (uint8_t)(dt->u.atomic.u.f.esize); + assert (dt->u.atomic.u.f.mpos<=255); + *(*pp)++ = (uint8_t)(dt->u.atomic.u.f.mpos); + assert (dt->u.atomic.u.f.msize<=255); + *(*pp)++ = (uint8_t)(dt->u.atomic.u.f.msize); + UINT32ENCODE(*pp, dt->u.atomic.u.f.ebias); + break; + + case H5T_COMPOUND: + /* + * Compound data types... + */ + flags = dt->u.compnd.nmembs & 0xffff; + for (i=0; i<dt->u.compnd.nmembs; i++) { + + /* Name, multiple of eight bytes */ + HDstrcpy((char*)(*pp), dt->u.compnd.memb[i].name); + n = HDstrlen(dt->u.compnd.memb[i].name); + for (z=n+1; z%8; z++) + (*pp)[z] = '\0'; + *pp += z; + + /* Member offset */ + UINT32ENCODE(*pp, dt->u.compnd.memb[i].offset); + + /* Dimensionality */ + *(*pp)++ = dt->u.compnd.memb[i].ndims; + assert(dt->u.compnd.memb[i].ndims <= 4); + + /* Reserved */ + *(*pp)++ = '\0'; + *(*pp)++ = '\0'; + *(*pp)++ = '\0'; + + /* Dimension permutation */ + for (j = 0, perm_word = 0; j < dt->u.compnd.memb[i].ndims; j++) { + perm_word |= dt->u.compnd.memb[i].perm[j] << (8 * j); + } + UINT32ENCODE(*pp, perm_word); + + /* Reserved */ + UINT32ENCODE(*pp, 0); + + /* Dimensions */ + for (j=0; j<dt->u.compnd.memb[i].ndims; j++) { + UINT32ENCODE(*pp, dt->u.compnd.memb[i].dim[j]); + } + for (/*void*/; j<4; j++) { + UINT32ENCODE(*pp, 0); + } + + /* Subtype */ + if (H5O_dtype_encode_helper(pp, dt->u.compnd.memb[i].type)<0) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, + "unable to encode member type"); + } + } + break; + + case H5T_ENUM: + /* + * Enumeration data types... + */ + flags = dt->u.enumer.nmembs & 0xffff; + + /* Parent type */ + if (H5O_dtype_encode_helper(pp, dt->parent)<0) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, + "unable to encode parent data type"); + } + + /* Names, each a multiple of eight bytes */ + for (i=0; i<dt->u.enumer.nmembs; i++) { + HDstrcpy((char*)(*pp), dt->u.enumer.name[i]); + n = HDstrlen(dt->u.enumer.name[i]); + for (z=n+1; z%8; z++) + (*pp)[z] = '\0'; + *pp += z; + } + + /* Values */ + HDmemcpy(*pp, dt->u.enumer.value, dt->u.enumer.nmembs * dt->parent->size); + *pp += dt->u.enumer.nmembs * dt->parent->size; + break; - case H5T_VLEN: /* Variable length datatypes... */ - /* Encode base type of VL information */ - if (H5O_dtype_encode_helper(pp, dt->parent)<0) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type"); - } - break; - - default: - /*nothing */ - break; + case H5T_REFERENCE: + flags |= (dt->u.atomic.u.r.rtype & 0x0f); + break; + + case H5T_STRING: + /* + * Character string types... (not fully implemented) + */ + assert (dt->u.atomic.order == H5T_ORDER_NONE); + assert (dt->u.atomic.prec == 8 * dt->size); + assert (dt->u.atomic.offset == 0); + assert (dt->u.atomic.lsb_pad == H5T_PAD_ZERO); + assert (dt->u.atomic.msb_pad == H5T_PAD_ZERO); + + flags |= (dt->u.atomic.u.s.pad & 0x0f); + flags |= (dt->u.atomic.u.s.cset & 0x0f) << 4; + break; + + case H5T_VLEN: /* Variable length datatypes... */ + flags |= (dt->u.vlen.type & 0x0f); + + /* Encode base type of VL information */ + if (H5O_dtype_encode_helper(pp, dt->parent)<0) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type"); + } + break; + + default: + /*nothing */ + break; } *hdr++ = ((uintn)(dt->type) & 0x0f) | (H5O_DTYPE_VERSION<<4); @@ -1541,7 +1541,7 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space) c1=H5S_select_contiguous(file_space); c2=H5S_select_contiguous(mem_space); if(c1==FAIL || c2==FAIL) - HRETURN_ERROR(H5E_DATASPACE, H5E_INTERNAL, NULL, + HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, NULL, "invalid check for contiguous dataspace "); if (c1==TRUE && c2==TRUE) { diff --git a/src/H5Sall.c b/src/H5Sall.c index d956b78..5800509 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -998,10 +998,10 @@ H5S_all_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t op /* Iterate through the entire dataset */ while(nelemts>0 && ret_value==0) { /* Get the offset in the memory buffer */ - offset=H5V_array_offset(rank+1,mem_size,mem_offset); + offset=H5V_array_offset(rank+1,mem_size,(const hssize_t *)mem_offset); tmp_buf=((char *)buf+offset); - ret_value=(*op)(tmp_buf,type_id,rank,mem_offset,operator_data); + ret_value=(*op)(tmp_buf,type_id,rank,(hssize_t *)mem_offset,operator_data); /* Decrement the number of elements to iterate through */ nelemts--; diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 0211c63..7e17323 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -1192,7 +1192,7 @@ H5S_point_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t mem_offset[rank]=0; /* Get the offset in the memory buffer */ - offset=H5V_array_offset(rank+1,mem_size,mem_offset); + offset=H5V_array_offset(rank+1,mem_size,(const hssize_t *)mem_offset); tmp_buf=((char *)buf+offset); ret_value=(*op)(tmp_buf,type_id,rank,node->pnt,operator_data); @@ -1848,11 +1848,19 @@ H5Tget_class(hid_t type_id) H5T_class_t H5T_get_class(const H5T_t *dt) { + H5T_class_t ret_value; + FUNC_ENTER(H5T_get_class, H5T_NO_CLASS); assert(dt); - FUNC_LEAVE(dt->type); + /* Lie to the user if they have a VL string and tell them it's in the string class */ + if(dt->type==H5T_VLEN && dt->u.vlen.type==H5T_VLEN_STRING) + ret_value=H5T_STRING; + else + ret_value=dt->type; + + FUNC_LEAVE(ret_value); } /* end H5T_get_class() */ @@ -3412,10 +3420,6 @@ H5Tget_member_type(hid_t type_id, int membno) * the member in an instance of the compound data type, and * MEMBER_ID is the type of the new member. * - * Note: All members of a compound data type must be atomic; a - * compound data type cannot have a member which is a compound - * data type. - * * Return: Success: Non-negative, the PARENT_ID compound data * type is modified to include a copy of the * member type MEMBER_ID. @@ -3930,11 +3934,14 @@ H5Tvlen_create(hid_t base_id) /* * Force conversions (i.e. memory to memory conversions should duplicate - * data, not point to the same VL sequences + * data, not point to the same VL sequences) */ dt->force_conv = TRUE; dt->parent = H5T_copy(base, H5T_COPY_ALL); + /* This is a sequence, not a string */ + dt->u.vlen.type = H5T_VLEN_SEQUENCE; + /* Set up VL information */ if (H5T_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0) { HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); @@ -5175,65 +5182,98 @@ H5T_set_size(H5T_t *dt, size_t size) assert(H5T_ENUM!=dt->type || 0==dt->u.enumer.nmembs); if (dt->parent) { - if (H5T_set_size(dt->parent, size)<0) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, - "unable to set size for parent data type"); - } - dt->size = dt->parent->size; + if (H5T_set_size(dt->parent, size)<0) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to set size for parent data type"); + } + dt->size = dt->parent->size; } else { - if (H5T_is_atomic(dt)) { - offset = dt->u.atomic.offset; - prec = dt->u.atomic.prec; - /* Decrement the offset and precision if necessary */ - if (prec > 8*size) offset = 0; - else if (offset+prec > 8*size) offset = 8 * size - prec; - if (prec > 8*size) prec = 8 * size; - } else { - prec = offset = 0; - } + if (H5T_is_atomic(dt)) { + offset = dt->u.atomic.offset; + prec = dt->u.atomic.prec; + + /* Decrement the offset and precision if necessary */ + if (prec > 8*size) + offset = 0; + else + if (offset+prec > 8*size) + offset = 8 * size - prec; + if (prec > 8*size) + prec = 8 * size; + } else { + prec = offset = 0; + } - switch (dt->type) { - case H5T_COMPOUND: - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, - "unable to set size of a compound data type"); + switch (dt->type) { + case H5T_COMPOUND: + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to set size of a compound data type"); + + case H5T_INTEGER: + case H5T_TIME: + case H5T_BITFIELD: + case H5T_ENUM: + case H5T_OPAQUE: + /* nothing to check */ + break; - case H5T_INTEGER: - case H5T_TIME: - case H5T_BITFIELD: - case H5T_ENUM: - case H5T_OPAQUE: - /* nothing to check */ - break; + case H5T_STRING: + /* Convert string to variable-length datatype */ + if(size==H5T_VARIABLE) { + H5T_t *base = NULL; /* base data type */ - case H5T_STRING: - prec = 8 * size; - offset = 0; - break; + /* Get a copy of unsigned char type as the base/parent type */ + if (NULL==(base=H5I_object(H5T_NATIVE_UCHAR))) + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype"); + dt->parent=H5T_copy(base,H5T_COPY_ALL); - case H5T_FLOAT: - /* - * The sign, mantissa, and exponent fields should be adjusted - * first when decreasing the size of a floating point type. - */ - if (dt->u.atomic.u.f.sign >= prec || - dt->u.atomic.u.f.epos + dt->u.atomic.u.f.esize > prec || - dt->u.atomic.u.f.mpos + dt->u.atomic.u.f.msize > prec) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "adjust sign, mantissa, and exponent fields " - "first"); - } - break; + /* change this datatype into a VL string */ + dt->type = H5T_VLEN; - default: - assert("not implemented yet" && 0); - } + /* + * Force conversions (i.e. memory to memory conversions should duplicate + * data, not point to the same VL strings) + */ + dt->force_conv = TRUE; - /* Commit */ - dt->size = size; - if (H5T_is_atomic(dt)) { - dt->u.atomic.offset = offset; - dt->u.atomic.prec = prec; - } + /* This is a string, not a sequence */ + dt->u.vlen.type = H5T_VLEN_STRING; + + /* Set up VL information */ + if (H5T_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0) + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); + + } else { + prec = 8 * size; + offset = 0; + } /* end else */ + break; + + case H5T_FLOAT: + /* + * The sign, mantissa, and exponent fields should be adjusted + * first when decreasing the size of a floating point type. + */ + if (dt->u.atomic.u.f.sign >= prec || + dt->u.atomic.u.f.epos + dt->u.atomic.u.f.esize > prec || + dt->u.atomic.u.f.mpos + dt->u.atomic.u.f.msize > prec) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "adjust sign, mantissa, and exponent fields first"); + } + break; + + default: + assert("not implemented yet" && 0); + } + + /* Commit */ + if(dt->type!=H5T_VLEN) { + dt->size = size; + if (H5T_is_atomic(dt)) { + dt->u.atomic.offset = offset; + dt->u.atomic.prec = prec; + } + } } FUNC_LEAVE(SUCCEED); diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 0b43fbe..2540204 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -1766,7 +1766,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs */ uint8_t **dptr; /*pointer to correct destination pointer*/ size_t src_delta, dst_delta; /*source & destination stride */ - hsize_t seq_len; /*the number of elements in the current sequence*/ + hssize_t seq_len; /*the number of elements in the current sequence*/ size_t src_base_size, dst_base_size;/*source & destination base size*/ size_t src_size, dst_size;/*source & destination total size in bytes*/ hid_t conv_buf_id; /*ID for comversion buffer */ @@ -1885,6 +1885,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Get length of sequences in bytes */ seq_len=(*(src->u.vlen.getlen))(src->u.vlen.f,s); + assert(seq_len>=0); src_size=seq_len*src_base_size; dst_size=seq_len*dst_base_size; diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index e0bac81..1ef3b24 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -86,13 +86,14 @@ typedef struct H5T_enum_t { } H5T_enum_t; /* VL function pointers */ -typedef hsize_t (*H5T_vlen_getlenfunc_t)(H5F_t *f, void *vl_addr); +typedef hssize_t (*H5T_vlen_getlenfunc_t)(H5F_t *f, void *vl_addr); typedef herr_t (*H5T_vlen_readfunc_t)(H5F_t *f, void *vl_addr, void *buf, size_t len); typedef herr_t (*H5T_vlen_writefunc_t)(const H5F_xfer_t *xfer_parms, H5F_t *f, void *vl_addr, void *buf, hsize_t seq_len, hsize_t base_size); /* A VL datatype */ typedef struct H5T_vlen_t { H5T_vlen_type_t type; /* Type of VL data in buffer */ + H5T_vlen_loc_t loc; /* Location of VL data in buffer */ H5F_t *f; /* File ID (if VL data is on disk) */ H5T_vlen_getlenfunc_t getlen; /* Function to get VL sequence size (in element units, not bytes) */ H5T_vlen_readfunc_t read; /* Function to read VL sequence into buffer */ @@ -537,10 +538,13 @@ __DLL__ ssize_t H5T_bit_find(uint8_t *buf, size_t offset, size_t size, __DLL__ htri_t H5T_bit_inc(uint8_t *buf, size_t start, size_t size); /* VL functions */ -__DLL__ hsize_t H5T_vlen_mem_getlen(H5F_t *f, void *vl_addr); -__DLL__ herr_t H5T_vlen_mem_read(H5F_t *f, void *vl_addr, void *_buf, size_t len); -__DLL__ herr_t H5T_vlen_mem_write(const H5F_xfer_t *xfer_parms, H5F_t *f, void *vl_addr, void *_buf, hsize_t seq_len, hsize_t base_size); -__DLL__ hsize_t H5T_vlen_disk_getlen(H5F_t *f, void *vl_addr); +__DLL__ hssize_t H5T_vlen_seq_mem_getlen(H5F_t *f, void *vl_addr); +__DLL__ herr_t H5T_vlen_seq_mem_read(H5F_t *f, void *vl_addr, void *_buf, size_t len); +__DLL__ herr_t H5T_vlen_seq_mem_write(const H5F_xfer_t *xfer_parms, H5F_t *f, void *vl_addr, void *_buf, hsize_t seq_len, hsize_t base_size); +__DLL__ hssize_t H5T_vlen_str_mem_getlen(H5F_t *f, void *vl_addr); +__DLL__ herr_t H5T_vlen_str_mem_read(H5F_t *f, void *vl_addr, void *_buf, size_t len); +__DLL__ herr_t H5T_vlen_str_mem_write(const H5F_xfer_t *xfer_parms, H5F_t *f, void *vl_addr, void *_buf, hsize_t seq_len, hsize_t base_size); +__DLL__ hssize_t H5T_vlen_disk_getlen(H5F_t *f, void *vl_addr); __DLL__ herr_t H5T_vlen_disk_read(H5F_t *f, void *vl_addr, void *_buf, size_t len); __DLL__ herr_t H5T_vlen_disk_write(const H5F_xfer_t *xfer_parms, H5F_t *f, void *vl_addr, void *_buf, hsize_t seq_len, hsize_t base_size); diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index ca11e99..4785a41 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -57,18 +57,26 @@ typedef struct H5T_path_t { * VL types allowed. */ typedef enum { - H5T_VLEN_BADTYPE = 0, /* invalid VL Type */ - H5T_VLEN_MEMORY, /* VL datatype stored in memory */ - H5T_VLEN_DISK, /* VL datatype stored on disk */ + H5T_VLEN_BADTYPE = -1, /* invalid VL Type */ + H5T_VLEN_SEQUENCE=0, /* VL sequence */ + H5T_VLEN_STRING, /* VL string */ H5T_VLEN_MAXTYPE /* highest type (Invalid as true type) */ } H5T_vlen_type_t; +typedef enum { + H5T_VLEN_BADLOC = 0, /* invalid VL Type */ + H5T_VLEN_MEMORY, /* VL data stored in memory */ + H5T_VLEN_DISK, /* VL data stored on disk */ + H5T_VLEN_MAXLOC /* highest type (Invalid as true type) */ +} H5T_vlen_loc_t; + /* * Internal data structure for passing information to H5T_vlen_get_buf_size */ typedef struct { hid_t dataset_id; /* ID of the dataset we are working on */ - hid_t space_id; /* ID of the dataset's dataspace we are working on */ + hid_t fspace_id; /* ID of the file dataset's dataspace we are working on */ + hid_t mspace_id; /* ID of the memory dataset's dataspace we are working on */ hid_t fl_tbuf_id; /* ID of the temporary buffer we are using for fixed-length data */ hid_t vl_tbuf_id; /* ID of the temporary buffer we are using for VL data */ hid_t xfer_pid; /* ID of the dataset xfer property list */ @@ -120,7 +128,7 @@ __DLL__ char *H5T_enum_nameof(H5T_t *dt, void *value, char *name/*out*/, __DLL__ herr_t H5T_enum_valueof(H5T_t *dt, const char *name, void *value/*out*/); __DLL__ herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, hsize_t UNUSED ndim, hssize_t UNUSED *point, void UNUSED *_op_data); -__DLL__ herr_t H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_type_t loc); +__DLL__ herr_t H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc); __DLL__ H5R_type_t H5T_get_ref_type(const H5T_t *dt); #endif diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index d9284f1..b735465 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -150,7 +150,8 @@ typedef enum H5T_pers_t { H5T_PERS_SOFT = 1 /*soft conversion function */ } H5T_pers_t; -/* Variable Length Datatype struct */ +/* Variable Length Datatype struct in memory */ +/* (This is only used for VL sequences, not VL strings, which are stored in char *'s) */ typedef struct { size_t len; /* Length of VL data (in base type units) */ void *p; /* Pointer to VL data */ diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index ea341db..c6cdd34 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -50,28 +50,40 @@ static herr_t H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_f *------------------------------------------------------------------------- */ static herr_t -H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_type_t loc) +H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc) { FUNC_ENTER (H5T_vlen_set_loc, FAIL); /* check parameters */ assert(dt); - assert(loc>H5T_VLEN_BADTYPE && loc<H5T_VLEN_MAXTYPE); + assert(loc>H5T_VLEN_BADLOC && loc<H5T_VLEN_MAXLOC); switch(loc) { case H5T_VLEN_MEMORY: /* Memory based VL datatype */ assert(f==NULL); /* Mark this type as being stored in memory */ - dt->u.vlen.type=H5T_VLEN_MEMORY; - - /* size in memory, disk size is different */ - dt->size = sizeof(hvl_t); - - /* Set up the function pointers to access the VL information (in memory) */ - dt->u.vlen.getlen=H5T_vlen_mem_getlen; - dt->u.vlen.read=H5T_vlen_mem_read; - dt->u.vlen.write=H5T_vlen_mem_write; + dt->u.vlen.loc=H5T_VLEN_MEMORY; + + if(dt->u.vlen.type==H5T_VLEN_SEQUENCE) { + /* size in memory, disk size is different */ + dt->size = sizeof(hvl_t); + + /* Set up the function pointers to access the VL sequence in memory */ + dt->u.vlen.getlen=H5T_vlen_seq_mem_getlen; + dt->u.vlen.read=H5T_vlen_seq_mem_read; + dt->u.vlen.write=H5T_vlen_seq_mem_write; + } else if(dt->u.vlen.type==H5T_VLEN_STRING) { + /* size in memory, disk size is different */ + dt->size = sizeof(char *); + + /* Set up the function pointers to access the VL string in memory */ + dt->u.vlen.getlen=H5T_vlen_str_mem_getlen; + dt->u.vlen.read=H5T_vlen_str_mem_read; + dt->u.vlen.write=H5T_vlen_str_mem_write; + } else { + assert(0 && "Invalid VL type"); + } /* Reset file ID (since this VL is in memory) */ dt->u.vlen.f=NULL; @@ -81,7 +93,7 @@ H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_type_t loc) assert(f); /* Mark this type as being stored on disk */ - dt->u.vlen.type=H5T_VLEN_DISK; + dt->u.vlen.loc=H5T_VLEN_DISK; /* * Size of element on disk is 4 bytes for the length, plus the size @@ -90,7 +102,8 @@ H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_type_t loc) */ dt->size = 4 + H5F_SIZEOF_ADDR(f) + 4; - /* Set up the function pointers to access the VL information (in memory) */ + /* 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->u.vlen.getlen=H5T_vlen_disk_getlen; dt->u.vlen.read=H5T_vlen_disk_read; dt->u.vlen.write=H5T_vlen_disk_write; @@ -108,7 +121,7 @@ H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_type_t loc) /*------------------------------------------------------------------------- - * Function: H5T_vlen_mem_getlen + * Function: H5T_vlen_seq_mem_getlen * * Purpose: Retrieves the length of a memory based VL element. * @@ -121,12 +134,12 @@ H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_type_t loc) * *------------------------------------------------------------------------- */ -hsize_t H5T_vlen_mem_getlen(H5F_t UNUSED *f, void *vl_addr) +hssize_t H5T_vlen_seq_mem_getlen(H5F_t UNUSED *f, void *vl_addr) { hvl_t *vl=(hvl_t *)vl_addr; /* Pointer to the user's hvl_t information */ - hsize_t ret_value = FAIL; /*return value */ + hssize_t ret_value = FAIL; /*return value */ - FUNC_ENTER (H5T_vlen_mem_getlen, FAIL); + FUNC_ENTER (H5T_vlen_seq_mem_getlen, FAIL); /* check parameters */ assert(vl); @@ -134,11 +147,11 @@ hsize_t H5T_vlen_mem_getlen(H5F_t UNUSED *f, void *vl_addr) ret_value=vl->len; FUNC_LEAVE (ret_value); -} /* end H5T_vlen_mem_getlen() */ +} /* end H5T_vlen_seq_mem_getlen() */ /*------------------------------------------------------------------------- - * Function: H5T_vlen_mem_read + * Function: H5T_vlen_seq_mem_read * * Purpose: "Reads" the memory based VL sequence into a buffer * @@ -151,11 +164,11 @@ hsize_t H5T_vlen_mem_getlen(H5F_t UNUSED *f, void *vl_addr) * *------------------------------------------------------------------------- */ -herr_t H5T_vlen_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t len) +herr_t H5T_vlen_seq_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t len) { hvl_t *vl=(hvl_t *)vl_addr; /* Pointer to the user's hvl_t information */ - FUNC_ENTER (H5T_vlen_mem_read, FAIL); + FUNC_ENTER (H5T_vlen_seq_mem_read, FAIL); /* check parameters */ assert(vl && vl->p); @@ -164,11 +177,11 @@ herr_t H5T_vlen_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t len) HDmemcpy(buf,vl->p,len); FUNC_LEAVE (SUCCEED); -} /* end H5T_vlen_mem_read() */ +} /* end H5T_vlen_seq_mem_read() */ /*------------------------------------------------------------------------- - * Function: H5T_vlen_mem_write + * Function: H5T_vlen_seq_mem_write * * Purpose: "Writes" the memory based VL sequence from a buffer * @@ -181,12 +194,12 @@ herr_t H5T_vlen_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t len) * *------------------------------------------------------------------------- */ -herr_t H5T_vlen_mem_write(const H5F_xfer_t *xfer_parms, H5F_t UNUSED *f, void *vl_addr, void *buf, hsize_t seq_len, hsize_t base_size) +herr_t H5T_vlen_seq_mem_write(const H5F_xfer_t *xfer_parms, H5F_t UNUSED *f, void *vl_addr, void *buf, hsize_t seq_len, hsize_t base_size) { hvl_t *vl=(hvl_t *)vl_addr; /* Pointer to the user's hvl_t information */ size_t len=seq_len*base_size; - FUNC_ENTER (H5T_vlen_mem_write, FAIL); + FUNC_ENTER (H5T_vlen_seq_mem_write, FAIL); /* check parameters */ assert(vl); @@ -206,13 +219,114 @@ herr_t H5T_vlen_mem_write(const H5F_xfer_t *xfer_parms, H5F_t UNUSED *f, void *v HDmemcpy(vl->p,buf,len); FUNC_LEAVE (SUCCEED); -} /* end H5T_vlen_mem_write() */ +} /* end H5T_vlen_seq_mem_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_vlen_str_mem_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 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hssize_t H5T_vlen_str_mem_getlen(H5F_t UNUSED *f, void *vl_addr) +{ + char *s=*(char **)vl_addr; /* Pointer to the user's hvl_t information */ + hssize_t ret_value = FAIL; /*return value */ + + FUNC_ENTER (H5T_vlen_str_mem_getlen, FAIL); + + /* check parameters */ + assert(s); + + ret_value=HDstrlen(s); + + FUNC_LEAVE (ret_value); +} /* end H5T_vlen_str_mem_getlen() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_vlen_str_mem_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 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t H5T_vlen_str_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t len) +{ + char *s=*(char **)vl_addr; /* Pointer to the user's hvl_t information */ + + FUNC_ENTER (H5T_vlen_str_mem_read, FAIL); + + /* check parameters */ + assert(s); + assert(buf); + + HDmemcpy(buf,s,len); + + FUNC_LEAVE (SUCCEED); +} /* end H5T_vlen_str_mem_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_vlen_str_mem_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 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t H5T_vlen_str_mem_write(const H5F_xfer_t *xfer_parms, H5F_t UNUSED *f, void *vl_addr, void *buf, hsize_t seq_len, hsize_t base_size) +{ + char **s=(char **)vl_addr; /* Pointer to the user's hvl_t information */ + size_t len=seq_len*base_size; + + FUNC_ENTER (H5T_vlen_str_mem_write, FAIL); + + /* check parameters */ + assert(buf); + + /* Use the user's memory allocation routine is one is defined */ + if(xfer_parms->vlen_alloc!=NULL) { + if(NULL==(*s=(xfer_parms->vlen_alloc)((seq_len+1)*base_size,xfer_parms->alloc_info))) + HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data"); + } /* end if */ + else { /* Default to system malloc */ + if(NULL==(*s=H5MM_malloc((seq_len+1)*base_size))) + HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data"); + } /* end else */ + + HDmemcpy(*s,buf,len); + (*s)[len]='\0'; + + FUNC_LEAVE (SUCCEED); +} /* end H5T_vlen_str_mem_write() */ /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_getlen * - * Purpose: Retrieves the length of a memory based VL element. + * Purpose: Retrieves the length of a disk based VL element. * * Return: Non-negative on success/Negative on failure * @@ -223,10 +337,10 @@ herr_t H5T_vlen_mem_write(const H5F_xfer_t *xfer_parms, H5F_t UNUSED *f, void *v * *------------------------------------------------------------------------- */ -hsize_t H5T_vlen_disk_getlen(H5F_t UNUSED *f, void *vl_addr) +hssize_t H5T_vlen_disk_getlen(H5F_t UNUSED *f, void *vl_addr) { uint8_t *vl=(uint8_t *)vl_addr; /* Pointer to the disk VL information */ - hsize_t ret_value = FAIL; /*return value */ + hssize_t ret_value = FAIL; /*return value */ FUNC_ENTER (H5T_vlen_disk_getlen, FAIL); @@ -242,7 +356,7 @@ hsize_t H5T_vlen_disk_getlen(H5F_t UNUSED *f, void *vl_addr) /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_read * - * Purpose: Reads the disk based VL sequence into a buffer + * Purpose: Reads the disk based VL element into a buffer * * Return: Non-negative on success/Negative on failure * @@ -284,7 +398,7 @@ herr_t H5T_vlen_disk_read(H5F_t *f, void *vl_addr, void *buf, size_t UNUSED len) /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_write * - * Purpose: Writes the disk based VL sequence from a buffer + * Purpose: Writes the disk based VL element from a buffer * * Return: Non-negative on success/Negative on failure * @@ -382,7 +496,7 @@ H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_func, void *fre /* Recurse on the VL information if it's VL or compound, then free VL sequence */ case H5T_VLEN: - { + if(dt->u.vlen.type==H5T_VLEN_SEQUENCE) { hvl_t *vl=(hvl_t *)elem; /* Temp. ptr to the vl info */ /* Recurse if it's VL or compound */ @@ -403,7 +517,15 @@ H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_func, void *fre (*free_func)(vl->p,free_info); else H5MM_xfree(vl->p); - } /* end case */ + } else if(dt->u.vlen.type==H5T_VLEN_STRING) { + /* Free the VL string */ + if(free_func!=NULL) + (*free_func)(*(char **)elem,free_info); + else + H5MM_xfree(*(char **)elem); + } else { + assert(0 && "Invalid VL type"); + } /* end else */ break; default: @@ -487,7 +609,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_type_t loc) +H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc) { intn i; /* local counting variable */ herr_t ret_value = SUCCEED; @@ -495,7 +617,7 @@ H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_type_t loc) FUNC_ENTER(H5T_vlen_mark, FAIL); assert(dt); - assert(loc>H5T_VLEN_BADTYPE && loc<H5T_VLEN_MAXTYPE); + assert(loc>H5T_VLEN_BADLOC && loc<H5T_VLEN_MAXLOC); /* Check the datatype of this element */ switch(dt->type) { diff --git a/src/H5config.h.in b/src/H5config.h.in index 1400056..0ae9639 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -299,9 +299,6 @@ /* Define if you have the <zlib.h> header file. */ #undef HAVE_ZLIB_H -/* Define if you have the coug library (-lcoug). */ -#undef HAVE_LIBCOUG - /* Define if you have the df library (-ldf). */ #undef HAVE_LIBDF |