summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5FD.c4
-rw-r--r--src/H5FDmulti.c54
-rw-r--r--src/H5FDsec2.c2
-rw-r--r--src/H5FDstdio.c6
-rw-r--r--src/H5Shyper.c4
-rw-r--r--src/H5Sselect.c2
-rw-r--r--src/H5T.c1192
-rw-r--r--src/H5Tconv.c904
-rw-r--r--src/H5Tprivate.h5
-rw-r--r--src/H5Tvlen.c232
10 files changed, 1241 insertions, 1164 deletions
diff --git a/src/H5FD.c b/src/H5FD.c
index d4a8d91..eb53777 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -182,7 +182,7 @@ H5FDregister(const H5FD_class_t *cls)
HRETURN_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL,
"`read' and/or `write' method is not defined");
}
- for (type=0; type<H5FD_MEM_NTYPES; type++) {
+ for (type=H5FD_MEM_DEFAULT; type<H5FD_MEM_NTYPES; type++) {
if (cls->fl_map[type]<H5FD_MEM_NOLIST ||
cls->fl_map[type]>=H5FD_MEM_NTYPES) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
@@ -856,7 +856,7 @@ H5FD_close(H5FD_t *file)
assert(file && file->cls);
/* Free all free-lists, leaking any memory thus described */
- for (i=0; i<H5FD_MEM_NTYPES; i++) {
+ for (i=H5FD_MEM_DEFAULT; i<H5FD_MEM_NTYPES; i++) {
for (cur=file->fl[i]; cur; cur=next) {
#ifdef H5F_DEBUG
nblocks++;
diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c
index 59c8f99..73ceb74 100644
--- a/src/H5FDmulti.c
+++ b/src/H5FDmulti.c
@@ -40,7 +40,7 @@
hbool_t _seen[H5FD_MEM_NTYPES]; \
\
memset(_seen, 0, sizeof _seen); \
- for (_unmapped=1; _unmapped<H5FD_MEM_NTYPES; _unmapped++) { \
+ for (_unmapped=H5FD_MEM_SUPER; _unmapped<H5FD_MEM_NTYPES; _unmapped++) { \
LOOPVAR = MAP[_unmapped]; \
if (H5FD_MEM_DEFAULT==LOOPVAR) LOOPVAR=_unmapped; \
assert(LOOPVAR>0 && LOOPVAR<H5FD_MEM_NTYPES); \
@@ -49,14 +49,14 @@
#define MAPPED_MEMBERS(MAP,LOOPVAR) { \
H5FD_mem_t _unmapped, LOOPVAR; \
\
- for (_unmapped=1; _unmapped<H5FD_MEM_NTYPES; _unmapped++) { \
+ for (_unmapped=H5FD_MEM_SUPER; _unmapped<H5FD_MEM_NTYPES; _unmapped++) { \
LOOPVAR = MAP[_unmapped]; \
if (H5FD_MEM_DEFAULT==LOOPVAR) LOOPVAR=_unmapped; \
assert(LOOPVAR>0 && LOOPVAR<H5FD_MEM_NTYPES);
#define ALL_MEMBERS(LOOPVAR) { \
H5FD_mem_t LOOPVAR; \
- for (LOOPVAR=0; LOOPVAR<H5FD_MEM_NTYPES; LOOPVAR++) {
+ for (LOOPVAR=H5FD_MEM_DEFAULT; LOOPVAR<H5FD_MEM_NTYPES; LOOPVAR++) {
#define END_MEMBERS }}
@@ -247,7 +247,7 @@ H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id,
H5Eclear();
/* Initialize */
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
memb_map[mt] = (H5FD_MEM_DRAW==mt?mt:H5FD_MEM_SUPER);
memb_fapl[mt] = -1;
memb_name[mt] = NULL;
@@ -375,33 +375,33 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map,
if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "not a file access property list", -1);
if (!memb_map) {
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
_memb_map[mt] = H5FD_MEM_DEFAULT;
}
memb_map = _memb_map;
}
if (!memb_fapl) {
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
_memb_fapl[mt] = H5P_DEFAULT;
}
memb_fapl = _memb_fapl;
}
if (!memb_name) {
assert(strlen(letters)==H5FD_MEM_NTYPES);
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
sprintf(_memb_name[mt], "%%s-%c.h5", letters[mt]);
_memb_name_ptrs[mt] = _memb_name[mt];
}
memb_name = _memb_name_ptrs;
}
if (!memb_addr) {
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
_memb_addr[mt] = (mt?mt-1:0) * HADDR_MAX/H5FD_MEM_NTYPES;
}
memb_addr = _memb_addr;
}
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
/* Map usage type */
mmt = memb_map[mt];
if (mmt<0 || mmt>=H5FD_MEM_NTYPES)
@@ -476,7 +476,7 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/,
memcpy(memb_map, fa->memb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t));
}
if (memb_fapl) {
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (fa->memb_fapl[mt]>=0) {
memb_fapl[mt] = H5Pcopy(fa->memb_fapl[mt]);
} else {
@@ -485,7 +485,7 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/,
}
}
if (memb_name) {
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (fa->memb_name[mt]) {
memb_name[mt] = malloc(strlen(fa->memb_name[mt])+1);
strcpy(memb_name[mt], fa->memb_name[mt]);
@@ -541,7 +541,7 @@ H5Pset_dxpl_multi(hid_t dxpl_id, const hid_t *memb_dxpl)
H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a data transfer property list", -1);
if (!memb_dxpl)
H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid pointer", -1);
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (H5P_DEFAULT!=memb_dxpl[mt] &&
H5P_DATA_XFER!=H5Pget_class(memb_dxpl[mt]))
H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a data transfer property list", -1);
@@ -590,7 +590,7 @@ H5Pget_dxpl_multi(hid_t dxpl_id, hid_t *memb_dxpl/*out*/)
H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "bad VFL driver info", -1);
if (memb_dxpl) {
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (dx->memb_dxpl[mt]>=0) {
memb_dxpl[mt] = H5Pcopy(dx->memb_dxpl[mt]);
} else {
@@ -692,7 +692,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/,
strcpy(name, "NCSAmulti");
assert(7==H5FD_MEM_NTYPES);
- for (m=1; m<H5FD_MEM_NTYPES; m++) {
+ for (m=H5FD_MEM_SUPER; m<H5FD_MEM_NTYPES; m++) {
buf[m-1] = file->fa.memb_map[m];
}
buf[7] = 0;
@@ -789,8 +789,8 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf)
*/
memset(map, 0, sizeof map);
for (i=0; i<6; i++) {
- map[i+1] = buf[i];
- if (file->fa.memb_map[i+1]!=map[i+1]) map_changed=TRUE;
+ map[i+1] = (H5FD_mem_t)buf[i];
+ if (file->fa.memb_map[i+1]!=map[i+1]) map_changed=TRUE;
}
UNIQUE_MEMBERS(map, mt) {
nseen++;
@@ -950,7 +950,7 @@ H5FD_multi_fapl_copy(const void *_old_fa)
H5Eclear();
memcpy(new_fa, old_fa, sizeof(H5FD_multi_fapl_t));
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (old_fa->memb_fapl[mt]>=0) {
new_fa->memb_fapl[mt] = H5Pcopy(old_fa->memb_fapl[mt]);
if (new_fa->memb_fapl[mt]<0) nerrors++;
@@ -963,7 +963,7 @@ H5FD_multi_fapl_copy(const void *_old_fa)
}
if (nerrors) {
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (new_fa->memb_fapl[mt]>=0) H5Pclose(new_fa->memb_fapl[mt]);
if (new_fa->memb_name[mt]) free(new_fa->memb_name[mt]);
}
@@ -999,7 +999,7 @@ H5FD_multi_fapl_free(void *_fa)
/* Clear the error stack */
H5Eclear();
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (fa->memb_fapl[mt]>=0) H5Pclose(fa->memb_fapl[mt]);
if (fa->memb_name[mt]) free(fa->memb_name[mt]);
}
@@ -1039,7 +1039,7 @@ H5FD_multi_dxpl_copy(const void *_old_dx)
H5Eclear();
memcpy(new_dx, old_dx, sizeof(H5FD_multi_dxpl_t));
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (old_dx->memb_dxpl[mt]>=0) {
new_dx->memb_dxpl[mt] = H5Pcopy(old_dx->memb_dxpl[mt]);
if (new_dx->memb_dxpl[mt]<0) nerrors++;
@@ -1047,7 +1047,7 @@ H5FD_multi_dxpl_copy(const void *_old_dx)
}
if (nerrors) {
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++)
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++)
H5Pclose(new_dx->memb_dxpl[mt]);
free(new_dx);
H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid freespace objects", NULL);
@@ -1081,7 +1081,7 @@ H5FD_multi_dxpl_free(void *_dx)
/* Clear the error stack */
H5Eclear();
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++)
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++)
if (dx->memb_dxpl[mt]>=0)
H5Pclose(dx->memb_dxpl[mt]);
free(dx);
@@ -1284,7 +1284,7 @@ H5FD_multi_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
/* Clear the error stack */
H5Eclear();
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) {
if (f1->memb[mt] && f2->memb[mt]) break;
if (!cmp) {
if (f1->memb[mt]) cmp = -1;
@@ -1359,7 +1359,7 @@ H5FD_multi_set_eoa(H5FD_t *_file, haddr_t eoa)
H5Eclear();
/* Find the subfile in which the new EOA value falls */
- for (mt=1; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt++) {
mmt = file->fa.memb_map[mt];
if (H5FD_MEM_DEFAULT==mmt) mmt = mt;
assert(mmt>0 && mmt<H5FD_MEM_NTYPES);
@@ -1549,7 +1549,7 @@ H5FD_multi_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
}
/* Find the file to which this address belongs */
- for (mt=1; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt++) {
mmt = file->fa.memb_map[mt];
if (H5FD_MEM_DEFAULT==mmt) mmt = mt;
assert(mmt>0 && mmt<H5FD_MEM_NTYPES);
@@ -1604,7 +1604,7 @@ H5FD_multi_write(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
}
/* Find the file to which this address belongs */
- for (mt=1; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt++) {
mmt = file->fa.memb_map[mt];
if (H5FD_MEM_DEFAULT==mmt) mmt = mt;
assert(mmt>0 && mmt<H5FD_MEM_NTYPES);
@@ -1683,7 +1683,7 @@ H5FD_multi_flush(H5FD_t *_file)
H5Eclear();
/* Flush each file */
- for (mt=1; mt<H5FD_MEM_NTYPES; mt++) {
+ for (mt=H5FD_MEM_SUPER; mt<H5FD_MEM_NTYPES; mt++) {
if (file->memb[mt]) {
H5E_BEGIN_TRY {
if (H5FDflush(file->memb[mt])<0) nerrors++;
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index db92793..8211145 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -657,7 +657,7 @@ H5FD_sec2_flush(H5FD_t *_file)
FUNC_ENTER(H5FD_sec2_seek, FAIL);
if (file->eoa>file->eof) {
- if (-1==file_seek(file->fd, file->eoa-1, SEEK_SET))
+ if (-1==file_seek(file->fd, (file_offset_t)(file->eoa-1), SEEK_SET))
HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL,
"unable to seek to proper position");
if (write(file->fd, "", 1)!=1)
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c
index 2122371..1c42900 100644
--- a/src/H5FDstdio.c
+++ b/src/H5FDstdio.c
@@ -564,7 +564,7 @@ H5FD_stdio_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
*/
if (!(file->op == H5FD_STDIO_OP_READ || file->op==H5FD_STDIO_OP_SEEK) ||
file->pos != addr) {
- if (fseek(file->fp, addr, SEEK_SET) < 0) {
+ if (fseek(file->fp, (long)addr, SEEK_SET) < 0) {
file->op = H5FD_STDIO_OP_UNKNOWN;
file->pos = HADDR_UNDEF;
H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fseek failed", -1);
@@ -653,7 +653,7 @@ H5FD_stdio_write(H5FD_t *_file, hid_t dxpl_id, haddr_t addr,
*/
if (!(file->op == H5FD_STDIO_OP_WRITE || file->op==H5FD_STDIO_OP_SEEK) ||
file->pos != addr) {
- if (fseek(file->fp, addr, SEEK_SET) < 0) {
+ if (fseek(file->fp, (long)addr, SEEK_SET) < 0) {
file->op = H5FD_STDIO_OP_UNKNOWN;
file->pos = HADDR_UNDEF;
H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fseek failed", -1);
@@ -718,7 +718,7 @@ H5FD_stdio_flush(H5FD_t *_file)
if(file->write_access) {
/* Makes sure that the true file size is the same (or larger) than the end-of-address. */
if (file->eoa>file->eof) {
- if (fseek(file->fp, file->eoa-1, SEEK_SET)<0)
+ if (fseek(file->fp, (long)(file->eoa-1), SEEK_SET)<0)
H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "fseek failed", -1);
if (fwrite("", 1, 1, file->fp)!=1)
H5Epush_ret(func, H5E_IO, H5E_SEEKERROR, "EOF fwrite failed", -1);
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 14d36de..18204f9 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -486,7 +486,7 @@ H5S_hyper_block_cache (H5S_hyper_node_t *node,
} /* end else */
/* Set up parameters for accessing block (starting the read and write information at the same point) */
- node->cinfo.wleft=node->cinfo.rleft=node->cinfo.size;
+ node->cinfo.wleft=node->cinfo.rleft=(uintn)node->cinfo.size;
node->cinfo.wpos=node->cinfo.rpos=node->cinfo.block;
/* Set cached flag */
@@ -3002,7 +3002,7 @@ H5S_hyper_select_contiguous(const H5S_t *space)
*
*-------------------------------------------------------------------------
*/
-static size_t
+static herr_t
H5S_hyper_select_iterate_mem (intn dim, H5S_hyper_iter_info_t *iter_info)
{
hsize_t offset; /* offset of region in buffer */
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index fdf7dc4..5b751c1 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -1161,7 +1161,7 @@ H5S_get_select_hyper_nblocks(H5S_t *space)
assert(space);
- ret_value = space->select.sel_info.hslab.hyper_lst->count;
+ ret_value = (hssize_t)space->select.sel_info.hslab.hyper_lst->count;
FUNC_LEAVE (ret_value);
} /* H5Sget_select_hyper_nblocks() */
diff --git a/src/H5T.c b/src/H5T.c
index 044441e..0f6e766 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -4085,161 +4085,163 @@ H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id,
/* Check args */
if (H5T_PERS_HARD!=pers && H5T_PERS_SOFT!=pers) {
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"invalid function persistence");
}
if (!name || !*name) {
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
"conversion must have a name for debugging");
}
if (H5I_DATATYPE!=H5I_get_type(src_id) ||
- NULL==(src=H5I_object(src_id)) ||
- H5I_DATATYPE!=H5I_get_type(dst_id) ||
- NULL==(dst=H5I_object(dst_id))) {
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ NULL==(src=H5I_object(src_id)) ||
+ H5I_DATATYPE!=H5I_get_type(dst_id) ||
+ NULL==(dst=H5I_object(dst_id))) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
if (!func) {
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"no conversion function specified");
}
if (H5T_PERS_HARD==pers) {
- /* Locate or create a new conversion path */
- if (NULL==(new_path=H5T_path_find(src, dst, name, func))) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to locate/allocate conversion path");
- }
-
- /*
- * Notify all other functions to recalculate private data since some
- * functions might cache a list of conversion functions. For
- * instance, the compound type converter caches a list of conversion
- * functions for the members, so adding a new function should cause
- * the list to be recalculated to use the new function.
- */
- for (i=0; i<H5T_g.npaths; i++) {
- if (new_path != H5T_g.path[i]) {
- H5T_g.path[i]->cdata.recalc = TRUE;
- }
- }
-
+ /* Locate or create a new conversion path */
+ if (NULL==(new_path=H5T_path_find(src, dst, name, func))) {
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to locate/allocate conversion path");
+ }
+
+ /*
+ * Notify all other functions to recalculate private data since some
+ * functions might cache a list of conversion functions. For
+ * instance, the compound type converter caches a list of conversion
+ * functions for the members, so adding a new function should cause
+ * the list to be recalculated to use the new function.
+ */
+ for (i=0; i<H5T_g.npaths; i++) {
+ if (new_path != H5T_g.path[i])
+ H5T_g.path[i]->cdata.recalc = TRUE;
+ }
+
} else {
- /* Add function to end of soft list */
- if (H5T_g.nsoft>=H5T_g.asoft) {
- size_t na = MAX(32, 2*H5T_g.asoft);
- H5T_soft_t *x = H5MM_realloc(H5T_g.soft, na*sizeof(H5T_soft_t));
- if (!x) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
- H5T_g.asoft = (intn)na;
- H5T_g.soft = x;
- }
- HDstrncpy (H5T_g.soft[H5T_g.nsoft].name, name, H5T_NAMELEN);
- H5T_g.soft[H5T_g.nsoft].name[H5T_NAMELEN-1] = '\0';
- H5T_g.soft[H5T_g.nsoft].src = src->type;
- H5T_g.soft[H5T_g.nsoft].dst = dst->type;
- H5T_g.soft[H5T_g.nsoft].func = func;
- H5T_g.nsoft++;
+ /* Add function to end of soft list */
+ if (H5T_g.nsoft>=H5T_g.asoft) {
+ size_t na = MAX(32, 2*H5T_g.asoft);
+ H5T_soft_t *x = H5MM_realloc(H5T_g.soft, na*sizeof(H5T_soft_t));
- /*
- * Any existing path (except the no-op path) to which this new soft
- * conversion function applies should be replaced by a new path that
- * uses this function.
- */
- for (i=1; i<H5T_g.npaths; i++) {
- old_path = H5T_g.path[i];
- assert(old_path);
-
- /* Does the new soft conversion function apply to this path? */
- if (old_path->is_hard ||
- old_path->src->type!=src->type ||
- old_path->dst->type!=dst->type) {
- continue;
- }
- if ((tmp_sid = H5I_register(H5I_DATATYPE,
- H5T_copy(old_path->src,
- H5T_COPY_ALL)))<0 ||
- (tmp_did = H5I_register(H5I_DATATYPE,
- H5T_copy(old_path->dst,
- H5T_COPY_ALL)))<0) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
- "unable to register data types for conv query");
- }
- HDmemset(&cdata, 0, sizeof cdata);
- cdata.command = H5T_CONV_INIT;
- if ((func)(tmp_sid, tmp_did, &cdata, 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
- H5I_dec_ref(tmp_sid);
- H5I_dec_ref(tmp_did);
- tmp_sid = tmp_did = -1;
- H5E_clear();
- continue;
- }
+ if (!x) {
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ H5T_g.asoft = (intn)na;
+ H5T_g.soft = x;
+ }
+ HDstrncpy (H5T_g.soft[H5T_g.nsoft].name, name, H5T_NAMELEN);
+ H5T_g.soft[H5T_g.nsoft].name[H5T_NAMELEN-1] = '\0';
+ H5T_g.soft[H5T_g.nsoft].src = src->type;
+ H5T_g.soft[H5T_g.nsoft].dst = dst->type;
+ H5T_g.soft[H5T_g.nsoft].func = func;
+ H5T_g.nsoft++;
- /* Create a new conversion path */
- if (NULL==(new_path=H5MM_calloc(sizeof(H5T_path_t)))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
- HDstrncpy(new_path->name, name, H5T_NAMELEN);
- new_path->name[H5T_NAMELEN-1] = '\0';
- if (NULL==(new_path->src=H5T_copy(old_path->src, H5T_COPY_ALL)) ||
- NULL==(new_path->dst=H5T_copy(old_path->dst, H5T_COPY_ALL))) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to copy data types");
- }
- new_path->func = func;
- new_path->is_hard = FALSE;
- new_path->cdata = cdata;
-
- /* Replace previous path */
- H5T_g.path[i] = new_path;
- new_path = NULL; /*so we don't free it on error*/
-
- /* Free old path */
- H5T_print_stats(old_path, &nprint);
- old_path->cdata.command = H5T_CONV_FREE;
- if ((old_path->func)(tmp_sid, tmp_did, &(old_path->cdata),
- 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
+ /*
+ * Any existing path (except the no-op path) to which this new soft
+ * conversion function applies should be replaced by a new path that
+ * uses this function.
+ */
+ for (i=1; i<H5T_g.npaths; i++) {
+ old_path = H5T_g.path[i];
+ assert(old_path);
+
+ /* Does the new soft conversion function apply to this path? */
+ if (old_path->is_hard ||
+ old_path->src->type!=src->type ||
+ old_path->dst->type!=dst->type) {
+ continue;
+ }
+ if ((tmp_sid = H5I_register(H5I_DATATYPE,
+ H5T_copy(old_path->src, H5T_COPY_ALL)))<0 ||
+ (tmp_did = H5I_register(H5I_DATATYPE,
+ H5T_copy(old_path->dst, H5T_COPY_ALL)))<0) {
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
+ "unable to register data types for conv query");
+ }
+ HDmemset(&cdata, 0, sizeof cdata);
+ cdata.command = H5T_CONV_INIT;
+ if ((func)(tmp_sid, tmp_did, &cdata, 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
+ H5I_dec_ref(tmp_sid);
+ H5I_dec_ref(tmp_did);
+ tmp_sid = tmp_did = -1;
+ H5E_clear();
+ continue;
+ }
+
+ /* Create a new conversion path */
+ if (NULL==(new_path=H5MM_calloc(sizeof(H5T_path_t)))) {
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ HDstrncpy(new_path->name, name, H5T_NAMELEN);
+ new_path->name[H5T_NAMELEN-1] = '\0';
+ if (NULL==(new_path->src=H5T_copy(old_path->src, H5T_COPY_ALL)) ||
+ NULL==(new_path->dst=H5T_copy(old_path->dst, H5T_COPY_ALL))) {
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to copy data types");
+ }
+ new_path->func = func;
+ new_path->is_hard = FALSE;
+ new_path->cdata = cdata;
+
+ /* Replace previous path */
+ H5T_g.path[i] = new_path;
+ new_path = NULL; /*so we don't free it on error*/
+
+ /* Free old path */
+ H5T_print_stats(old_path, &nprint);
+ old_path->cdata.command = H5T_CONV_FREE;
+ if ((old_path->func)(tmp_sid, tmp_did, &(old_path->cdata),
+ 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
#ifdef H5T_DEBUG
- if (H5DEBUG(T)) {
- fprintf (H5DEBUG(T), "H5T: conversion function 0x%08lx "
- "failed to free private data for %s (ignored)\n",
- (unsigned long)(old_path->func), old_path->name);
- }
+ if (H5DEBUG(T)) {
+ fprintf (H5DEBUG(T), "H5T: conversion function 0x%08lx "
+ "failed to free private data for %s (ignored)\n",
+ (unsigned long)(old_path->func), old_path->name);
+ }
#endif
- }
- H5T_close(old_path->src);
- H5T_close(old_path->dst);
- H5MM_xfree(old_path);
+ }
+ H5T_close(old_path->src);
+ H5T_close(old_path->dst);
+ H5MM_xfree(old_path);
- /* Release temporary atoms */
- H5I_dec_ref(tmp_sid);
- H5I_dec_ref(tmp_did);
- tmp_sid = tmp_did = -1;
+ /* Release temporary atoms */
+ H5I_dec_ref(tmp_sid);
+ H5I_dec_ref(tmp_did);
+ tmp_sid = tmp_did = -1;
- /* We don't care about any failures during the freeing process */
- H5E_clear();
- }
+ /* We don't care about any failures during the freeing process */
+ H5E_clear();
+ }
}
ret_value = SUCCEED;
done:
if (ret_value<0) {
- if (new_path) {
- if (new_path->src) H5T_close(new_path->src);
- if (new_path->dst) H5T_close(new_path->dst);
- H5MM_xfree(new_path);
- }
- if (tmp_sid>=0) H5I_dec_ref(tmp_sid);
- if (tmp_did>=0) H5I_dec_ref(tmp_did);
+ if (new_path) {
+ if (new_path->src)
+ H5T_close(new_path->src);
+ if (new_path->dst)
+ H5T_close(new_path->dst);
+ H5MM_xfree(new_path);
+ }
+ if (tmp_sid>=0)
+ H5I_dec_ref(tmp_sid);
+ if (tmp_did>=0)
+ H5I_dec_ref(tmp_did);
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * Function: H5Tunregister
+ * Function: H5T_unregister
*
* Purpose: Removes conversion paths that match the specified criteria.
* All arguments are optional. Missing arguments are wild cards.
@@ -4253,84 +4255,115 @@ H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id,
* Tuesday, January 13, 1998
*
* Modifications:
+ * Adapted to non-API function - QAK, 11/17/99
*
*-------------------------------------------------------------------------
*/
herr_t
-H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id,
+H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
H5T_conv_t func)
{
H5T_path_t *path = NULL; /*conversion path */
H5T_soft_t *soft = NULL; /*soft conversion information */
- H5T_t *src=NULL, *dst=NULL; /*data type descriptors */
intn nprint=0; /*number of paths shut down */
intn i; /*counter */
- FUNC_ENTER(H5Tunregister, FAIL);
- H5TRACE5("e","Tesiix",pers,name,src_id,dst_id,func);
-
- /* Check arguments */
- if (src_id>0 &&
- (H5I_DATATYPE!=H5I_get_type(src_id) ||
- NULL==(src=H5I_object(src_id)))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "src is not a data type");
- }
- if (dst_id>0 &&
- (H5I_DATATYPE!=H5I_get_type(dst_id) ||
- NULL==(dst=H5I_object(dst_id)))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dst is not a data type");
- }
+ FUNC_ENTER(H5T_unregister, FAIL);
/* Remove matching entries from the soft list */
if (H5T_PERS_DONTCARE==pers || H5T_PERS_SOFT==pers) {
- for (i=H5T_g.nsoft-1; i>=0; --i) {
- soft = H5T_g.soft+i;
- assert(soft);
- if (name && *name && HDstrcmp(name, soft->name)) continue;
- if (src && src->type!=soft->src) continue;
- if (dst && dst->type!=soft->dst) continue;
- if (func && func!=soft->func) continue;
-
- HDmemmove(H5T_g.soft+i, H5T_g.soft+i+1,
- (H5T_g.nsoft-(i+1)) * sizeof(H5T_soft_t));
- --H5T_g.nsoft;
- }
+ for (i=H5T_g.nsoft-1; i>=0; --i) {
+ soft = H5T_g.soft+i;
+ assert(soft);
+ if (name && *name && HDstrcmp(name, soft->name)) continue;
+ if (src && src->type!=soft->src) continue;
+ if (dst && dst->type!=soft->dst) continue;
+ if (func && func!=soft->func) continue;
+
+ HDmemmove(H5T_g.soft+i, H5T_g.soft+i+1,
+ (H5T_g.nsoft-(i+1)) * sizeof(H5T_soft_t));
+ --H5T_g.nsoft;
+ }
}
/* Remove matching conversion paths, except no-op path */
for (i=H5T_g.npaths-1; i>0; --i) {
- path = H5T_g.path[i];
- assert(path);
- if ((H5T_PERS_SOFT==pers && path->is_hard) ||
- (H5T_PERS_HARD==pers && !path->is_hard)) continue;
- if (name && *name && HDstrcmp(name, path->name)) continue;
- if (src && H5T_cmp(src, path->src)) continue;
- if (dst && H5T_cmp(dst, path->dst)) continue;
- if (func && func!=path->func) continue;
-
- /* Remove from table */
- HDmemmove(H5T_g.path+i, H5T_g.path+i+1,
- (H5T_g.npaths-(i+1))*sizeof(H5T_path_t*));
- --H5T_g.npaths;
-
- /* Shut down path */
- H5T_print_stats(path, &nprint);
- path->cdata.command = H5T_CONV_FREE;
- if ((path->func)(FAIL, FAIL, &(path->cdata), 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
+ path = H5T_g.path[i];
+ assert(path);
+ if ((H5T_PERS_SOFT==pers && path->is_hard) ||
+ (H5T_PERS_HARD==pers && !path->is_hard)) continue;
+ if (name && *name && HDstrcmp(name, path->name)) continue;
+ if (src && H5T_cmp(src, path->src)) continue;
+ if (dst && H5T_cmp(dst, path->dst)) continue;
+ if (func && func!=path->func) continue;
+
+ /* Remove from table */
+ HDmemmove(H5T_g.path+i, H5T_g.path+i+1,
+ (H5T_g.npaths-(i+1))*sizeof(H5T_path_t*));
+ --H5T_g.npaths;
+
+ /* Shut down path */
+ H5T_print_stats(path, &nprint);
+ path->cdata.command = H5T_CONV_FREE;
+ if ((path->func)(FAIL, FAIL, &(path->cdata), 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
#ifdef H5T_DEBUG
- if (H5DEBUG(T)) {
- fprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx failed "
- "to free private data for %s (ignored)\n",
- (unsigned long)(path->func), path->name);
- }
+ if (H5DEBUG(T)) {
+ fprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx failed "
+ "to free private data for %s (ignored)\n",
+ (unsigned long)(path->func), path->name);
+ }
#endif
- }
- H5T_close(path->src);
- H5T_close(path->dst);
- H5MM_xfree(path);
- H5E_clear(); /*ignore all shutdown errors*/
+ }
+ H5T_close(path->src);
+ H5T_close(path->dst);
+ H5MM_xfree(path);
+ H5E_clear(); /*ignore all shutdown errors*/
+ }
+
+ FUNC_LEAVE(SUCCEED);
+} /* end H5T_unregister() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tunregister
+ *
+ * Purpose: Removes conversion paths that match the specified criteria.
+ * All arguments are optional. Missing arguments are wild cards.
+ * The special no-op path cannot be removed.
+ *
+ * Return: Succeess: non-negative
+ *
+ * Failure: negative
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, January 13, 1998
+ *
+ * Modifications:
+ * Changed to use H5T_unregister wrapper function - QAK, 11/17/99
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id,
+ H5T_conv_t func)
+{
+ H5T_t *src=NULL, *dst=NULL; /*data type descriptors */
+
+ FUNC_ENTER(H5Tunregister, FAIL);
+ H5TRACE5("e","Tesiix",pers,name,src_id,dst_id,func);
+
+ /* Check arguments */
+ if (src_id>0 && (H5I_DATATYPE!=H5I_get_type(src_id) ||
+ NULL==(src=H5I_object(src_id)))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "src is not a data type");
+ }
+ if (dst_id>0 && (H5I_DATATYPE!=H5I_get_type(dst_id) ||
+ NULL==(dst=H5I_object(dst_id)))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dst is not a data type");
}
+ if (H5T_unregister(pers,name,src,dst,func)<0)
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "internal unregister function failed");
+
FUNC_LEAVE(SUCCEED);
}
@@ -4439,7 +4472,7 @@ H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf,
}
if (H5T_convert(tpath, src_id, dst_id, nelmts, 0, buf, background, plist_id)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"data type conversion failed");
}
@@ -4771,52 +4804,52 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
/* copy */
if (NULL==(new_dt = H5MM_calloc(sizeof(H5T_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
*new_dt = *old_dt;
/* copy parent */
if (new_dt->parent) {
- new_dt->parent = H5T_copy(new_dt->parent, method);
+ new_dt->parent = H5T_copy(new_dt->parent, method);
}
switch (method) {
- case H5T_COPY_TRANSIENT:
- /*
- * Return an unlocked transient type.
- */
- new_dt->state = H5T_STATE_TRANSIENT;
- HDmemset (&(new_dt->ent), 0, sizeof(new_dt->ent));
- new_dt->ent.header = HADDR_UNDEF;
- break;
-
- case H5T_COPY_ALL:
- /*
- * 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->state) {
- new_dt->state = H5T_STATE_NAMED;
- } else if (H5T_STATE_IMMUTABLE==new_dt->state) {
- new_dt->state = H5T_STATE_RDONLY;
- }
- break;
-
- case H5T_COPY_REOPEN:
- /*
- * Return a transient type (locked or unlocked) or an opened named
- * type.
- */
- if (H5F_addr_defined(new_dt->ent.header)) {
- if (H5O_open (&(new_dt->ent))<0) {
- H5MM_xfree (new_dt);
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL,
- "unable to reopen named data type");
- }
- new_dt->state = H5T_STATE_OPEN;
- }
- break;
+ case H5T_COPY_TRANSIENT:
+ /*
+ * Return an unlocked transient type.
+ */
+ new_dt->state = H5T_STATE_TRANSIENT;
+ HDmemset (&(new_dt->ent), 0, sizeof(new_dt->ent));
+ new_dt->ent.header = HADDR_UNDEF;
+ break;
+
+ case H5T_COPY_ALL:
+ /*
+ * 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->state) {
+ new_dt->state = H5T_STATE_NAMED;
+ } else if (H5T_STATE_IMMUTABLE==new_dt->state) {
+ new_dt->state = H5T_STATE_RDONLY;
+ }
+ break;
+
+ case H5T_COPY_REOPEN:
+ /*
+ * Return a transient type (locked or unlocked) or an opened named
+ * type.
+ */
+ if (H5F_addr_defined(new_dt->ent.header)) {
+ if (H5O_open (&(new_dt->ent))<0) {
+ H5MM_xfree (new_dt);
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL,
+ "unable to reopen named data type");
+ }
+ new_dt->state = H5T_STATE_OPEN;
+ }
+ break;
}
if (H5T_COMPOUND == new_dt->type) {
@@ -4862,25 +4895,23 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
new_dt->size += accum_change;
} else if (H5T_ENUM == new_dt->type) {
- /*
- * Copy all member fields to new type, then overwrite the name fields
- * of each new member with copied values. That is, H5T_copy() is a
- * deep copy.
- */
- new_dt->u.enumer.name = H5MM_malloc(new_dt->u.enumer.nalloc *
- sizeof(char*));
- new_dt->u.enumer.value = H5MM_malloc(new_dt->u.enumer.nalloc *
- new_dt->size);
- if (NULL==new_dt->u.enumer.value) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
- HDmemcpy(new_dt->u.enumer.value, old_dt->u.enumer.value,
- new_dt->u.enumer.nmembs * new_dt->size);
- for (i=0; i<new_dt->u.enumer.nmembs; i++) {
- s = old_dt->u.enumer.name[i];
- new_dt->u.enumer.name[i] = H5MM_xstrdup(s);
- }
+ /*
+ * Copy all member fields to new type, then overwrite the name fields
+ * of each new member with copied values. That is, H5T_copy() is a
+ * deep copy.
+ */
+ new_dt->u.enumer.name = H5MM_malloc(new_dt->u.enumer.nalloc * sizeof(char*));
+ new_dt->u.enumer.value = H5MM_malloc(new_dt->u.enumer.nalloc * new_dt->size);
+ if (NULL==new_dt->u.enumer.value) {
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ HDmemcpy(new_dt->u.enumer.value, old_dt->u.enumer.value,
+ new_dt->u.enumer.nmembs * new_dt->size);
+ for (i=0; i<new_dt->u.enumer.nmembs; i++) {
+ s = old_dt->u.enumer.name[i];
+ new_dt->u.enumer.name[i] = H5MM_xstrdup(s);
+ }
} else if (H5T_VLEN == new_dt->type) {
if(method==H5T_COPY_TRANSIENT || method==H5T_COPY_REOPEN) {
/* H5T_copy converts any VL type into a memory VL type */
@@ -5524,59 +5555,60 @@ H5T_struct_insert(H5T_t *parent, const char *name, size_t offset, intn ndims,
assert(name && *name);
/* Does NAME already exist in PARENT? */
- for (i=0; i<parent->u.compnd.nmembs; i++) {
- if (!HDstrcmp(parent->u.compnd.memb[i].name, name)) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
- "member name is not unique");
- }
- }
+ for (i=0; i<parent->u.compnd.nmembs; i++)
+ if (!HDstrcmp(parent->u.compnd.memb[i].name, name)) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
+ "member name is not unique");
+ }
/* Does the new member overlap any existing member ? */
- for (total_size=member->size, i=0; i<ndims; i++) total_size *= dim[i];
+ for (total_size=member->size, i=0; i<ndims; i++)
+ total_size *= dim[i];
for (i=0; i<parent->u.compnd.nmembs; i++) {
- if ((offset <= parent->u.compnd.memb[i].offset &&
- offset + total_size > parent->u.compnd.memb[i].offset) ||
- (parent->u.compnd.memb[i].offset <= offset &&
- parent->u.compnd.memb[i].offset +
- parent->u.compnd.memb[i].size > offset)) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
- "member overlaps with another member");
- }
+ if ((offset <= parent->u.compnd.memb[i].offset &&
+ offset + total_size > parent->u.compnd.memb[i].offset) ||
+ (parent->u.compnd.memb[i].offset <= offset &&
+ parent->u.compnd.memb[i].offset +
+ parent->u.compnd.memb[i].size > offset)) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
+ "member overlaps with another member");
+ }
}
/* Are permutations correct? */
if (ndims>0 && perm) {
- if (NULL==(perm_check=H5MM_calloc(ndims*sizeof(hbool_t)))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
- for (i=0; i<ndims; i++) {
- if (perm[i]<0 || perm[i]>=ndims) {
- H5MM_xfree(perm_check);
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "invalid permutation vector (out of range)");
- }
- if (perm_check[perm[i]]) {
- H5MM_xfree(perm_check);
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "invalid permutation vector (duplicate value)");
- }
- perm_check[perm[i]] = TRUE;
- }
- perm_check = H5MM_xfree(perm_check);
+ if (NULL==(perm_check=H5MM_calloc(ndims*sizeof(hbool_t)))) {
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ for (i=0; i<ndims; i++) {
+ if (perm[i]<0 || perm[i]>=ndims) {
+ H5MM_xfree(perm_check);
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "invalid permutation vector (out of range)");
+ }
+ if (perm_check[perm[i]]) {
+ H5MM_xfree(perm_check);
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "invalid permutation vector (duplicate value)");
+ }
+ perm_check[perm[i]] = TRUE;
+ }
+ perm_check = H5MM_xfree(perm_check);
}
/* Increase member array if necessary */
if (parent->u.compnd.nmembs >= parent->u.compnd.nalloc) {
- size_t na = parent->u.compnd.nalloc + H5T_COMPND_INC;
- H5T_cmemb_t *x = H5MM_realloc (parent->u.compnd.memb,
- na * sizeof(H5T_cmemb_t));
- if (!x) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
- parent->u.compnd.nalloc = (intn)na;
- parent->u.compnd.memb = x;
+ size_t na = parent->u.compnd.nalloc + H5T_COMPND_INC;
+ H5T_cmemb_t *x = H5MM_realloc (parent->u.compnd.memb,
+ na * sizeof(H5T_cmemb_t));
+
+ if (!x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ parent->u.compnd.nalloc = (intn)na;
+ parent->u.compnd.memb = x;
}
/* Add member to end of member array */
@@ -5587,8 +5619,8 @@ H5T_struct_insert(H5T_t *parent, const char *name, size_t offset, intn ndims,
parent->u.compnd.memb[idx].ndims = ndims;
parent->u.compnd.memb[idx].type = H5T_copy (member, H5T_COPY_ALL);
for (i=0; i<ndims; i++) {
- parent->u.compnd.memb[idx].dim[i] = dim[i];
- parent->u.compnd.memb[idx].perm[i] = perm?perm[i]:i;
+ parent->u.compnd.memb[idx].dim[i] = dim[i];
+ parent->u.compnd.memb[idx].perm[i] = perm ? perm[i] : i;
}
parent->u.compnd.sorted = H5T_SORT_NONE;
@@ -6124,169 +6156,184 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
if (dt1->parent && !dt2->parent) HGOTO_DONE(-1);
if (!dt1->parent && dt2->parent) HGOTO_DONE(1);
if (dt1->parent) {
- tmp = H5T_cmp(dt1->parent, dt2->parent);
- if (tmp<0) HGOTO_DONE(-1);
- if (tmp>0) HGOTO_DONE(1);
+ tmp = H5T_cmp(dt1->parent, dt2->parent);
+ if (tmp<0) HGOTO_DONE(-1);
+ if (tmp>0) HGOTO_DONE(1);
}
if (H5T_COMPOUND == dt1->type) {
- /*
- * Compound data types...
- */
- if (dt1->u.compnd.nmembs < dt2->u.compnd.nmembs) HGOTO_DONE(-1);
- if (dt1->u.compnd.nmembs > dt2->u.compnd.nmembs) HGOTO_DONE(1);
+ /*
+ * Compound data types...
+ */
+ if (dt1->u.compnd.nmembs < dt2->u.compnd.nmembs) HGOTO_DONE(-1);
+ if (dt1->u.compnd.nmembs > dt2->u.compnd.nmembs) HGOTO_DONE(1);
- /* Build an index for each type so the names are sorted */
- if (NULL==(idx1 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(intn))) ||
- NULL==(idx2 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(intn)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0,
- "memory allocation failed");
- }
- for (i=0; i<dt1->u.compnd.nmembs; i++) idx1[i] = idx2[i] = i;
- for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
- for (j=0, swapped=FALSE; j<i; j++) {
- if (HDstrcmp(dt1->u.compnd.memb[idx1[j]].name,
- dt1->u.compnd.memb[idx1[j+1]].name) > 0) {
- tmp = idx1[j];
- idx1[j] = idx1[j+1];
- idx1[j+1] = tmp;
- swapped = TRUE;
- }
- }
- }
- for (i=dt2->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
- for (j=0, swapped=FALSE; j<i; j++) {
- if (HDstrcmp(dt2->u.compnd.memb[idx2[j]].name,
- dt2->u.compnd.memb[idx2[j+1]].name) > 0) {
- tmp = idx2[j];
- idx2[j] = idx2[j+1];
- idx2[j+1] = tmp;
- swapped = TRUE;
- }
- }
- }
+ /* Build an index for each type so the names are sorted */
+ if (NULL==(idx1 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(intn))) ||
+ NULL==(idx2 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(intn)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0,
+ "memory allocation failed");
+ }
+ for (i=0; i<dt1->u.compnd.nmembs; i++)
+ idx1[i] = idx2[i] = i;
+ for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
+ for (j=0, swapped=FALSE; j<i; j++) {
+ if (HDstrcmp(dt1->u.compnd.memb[idx1[j]].name,
+ dt1->u.compnd.memb[idx1[j+1]].name) > 0) {
+ tmp = idx1[j];
+ idx1[j] = idx1[j+1];
+ idx1[j+1] = tmp;
+ swapped = TRUE;
+ }
+ }
+ }
+ for (i=dt2->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
+ for (j=0, swapped=FALSE; j<i; j++) {
+ if (HDstrcmp(dt2->u.compnd.memb[idx2[j]].name,
+ dt2->u.compnd.memb[idx2[j+1]].name) > 0) {
+ tmp = idx2[j];
+ idx2[j] = idx2[j+1];
+ idx2[j+1] = tmp;
+ swapped = TRUE;
+ }
+ }
+ }
#ifdef H5T_DEBUG
- /* I don't quite trust the code above yet :-) --RPM */
- for (i=0; i<dt1->u.compnd.nmembs-1; i++) {
- assert(HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
- dt1->u.compnd.memb[idx1[i + 1]].name));
- assert(HDstrcmp(dt2->u.compnd.memb[idx2[i]].name,
- dt2->u.compnd.memb[idx2[i + 1]].name));
- }
+ /* I don't quite trust the code above yet :-) --RPM */
+ for (i=0; i<dt1->u.compnd.nmembs-1; i++) {
+ assert(HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
+ dt1->u.compnd.memb[idx1[i + 1]].name));
+ assert(HDstrcmp(dt2->u.compnd.memb[idx2[i]].name,
+ dt2->u.compnd.memb[idx2[i + 1]].name));
+ }
#endif
- /* Compare the members */
- for (i=0; i<dt1->u.compnd.nmembs; i++) {
- tmp = HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
- dt2->u.compnd.memb[idx2[i]].name);
- if (tmp < 0) HGOTO_DONE(-1);
- if (tmp > 0) HGOTO_DONE(1);
-
- if (dt1->u.compnd.memb[idx1[i]].offset <
- dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(-1);
- if (dt1->u.compnd.memb[idx1[i]].offset >
- dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(1);
-
- if (dt1->u.compnd.memb[idx1[i]].size <
- dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(-1);
- if (dt1->u.compnd.memb[idx1[i]].size >
- dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(1);
-
- if (dt1->u.compnd.memb[idx1[i]].ndims <
- dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE(-1);
- if (dt1->u.compnd.memb[idx1[i]].ndims >
- dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE(1);
-
- for (j=0; j<dt1->u.compnd.memb[idx1[i]].ndims; j++) {
- if (dt1->u.compnd.memb[idx1[i]].dim[j] <
- dt2->u.compnd.memb[idx2[i]].dim[j]) HGOTO_DONE(-1);
- if (dt1->u.compnd.memb[idx1[i]].dim[j] >
- dt2->u.compnd.memb[idx2[i]].dim[j]) HGOTO_DONE(1);
- }
+ /* Compare the members */
+ for (i=0; i<dt1->u.compnd.nmembs; i++) {
+ tmp = HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
+ dt2->u.compnd.memb[idx2[i]].name);
+ if (tmp < 0) HGOTO_DONE(-1);
+ if (tmp > 0) HGOTO_DONE(1);
+
+ if (dt1->u.compnd.memb[idx1[i]].offset <
+ dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[i]].offset >
+ dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(1);
+
+ if (dt1->u.compnd.memb[idx1[i]].size <
+ dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[i]].size >
+ dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(1);
+
+ if (dt1->u.compnd.memb[idx1[i]].ndims <
+ dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[i]].ndims >
+ dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE(1);
+
+ for (j=0; j<dt1->u.compnd.memb[idx1[i]].ndims; j++) {
+ if (dt1->u.compnd.memb[idx1[i]].dim[j] <
+ dt2->u.compnd.memb[idx2[i]].dim[j]) HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[i]].dim[j] >
+ dt2->u.compnd.memb[idx2[i]].dim[j]) HGOTO_DONE(1);
+ }
- for (j=0; j<dt1->u.compnd.memb[idx1[i]].ndims; j++) {
- if (dt1->u.compnd.memb[idx1[i]].perm[j] <
- dt2->u.compnd.memb[idx2[i]].perm[j]) HGOTO_DONE(-1);
- if (dt1->u.compnd.memb[idx1[i]].perm[j] >
- dt2->u.compnd.memb[idx2[i]].perm[j]) HGOTO_DONE(1);
- }
+ for (j=0; j<dt1->u.compnd.memb[idx1[i]].ndims; j++) {
+ if (dt1->u.compnd.memb[idx1[i]].perm[j] <
+ dt2->u.compnd.memb[idx2[i]].perm[j]) HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[i]].perm[j] >
+ dt2->u.compnd.memb[idx2[i]].perm[j]) HGOTO_DONE(1);
+ }
- tmp = H5T_cmp(dt1->u.compnd.memb[idx1[i]].type,
- dt2->u.compnd.memb[idx2[i]].type);
- if (tmp < 0) HGOTO_DONE(-1);
- if (tmp > 0) HGOTO_DONE(1);
- }
-
+ tmp = H5T_cmp(dt1->u.compnd.memb[idx1[i]].type,
+ dt2->u.compnd.memb[idx2[i]].type);
+ if (tmp < 0) HGOTO_DONE(-1);
+ if (tmp > 0) HGOTO_DONE(1);
+ }
+
} else if (H5T_ENUM==dt1->type) {
- /*
- * Enumeration data types...
- */
- if (dt1->u.enumer.nmembs < dt2->u.enumer.nmembs) HGOTO_DONE(-1);
- if (dt1->u.enumer.nmembs > dt2->u.enumer.nmembs) HGOTO_DONE(1);
+ /*
+ * Enumeration data types...
+ */
+ if (dt1->u.enumer.nmembs < dt2->u.enumer.nmembs) HGOTO_DONE(-1);
+ if (dt1->u.enumer.nmembs > dt2->u.enumer.nmembs) HGOTO_DONE(1);
- /* Build an index for each type so the names are sorted */
- if (NULL==(idx1 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(intn))) ||
- NULL==(idx2 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(intn)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0,
- "memory allocation failed");
- }
- for (i=0; i<dt1->u.enumer.nmembs; i++) idx1[i] = idx2[i] = i;
- for (i=dt1->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
- for (j=0, swapped=FALSE; j<i; j++) {
- if (HDstrcmp(dt1->u.enumer.name[idx1[j]],
- dt1->u.enumer.name[idx1[j+1]]) > 0) {
- tmp = idx1[j];
- idx1[j] = idx1[j+1];
- idx1[j+1] = tmp;
- swapped = TRUE;
- }
- }
- }
- for (i=dt2->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
- for (j=0, swapped=FALSE; j<i; j++) {
- if (HDstrcmp(dt2->u.enumer.name[idx2[j]],
- dt2->u.enumer.name[idx2[j+1]]) > 0) {
- tmp = idx2[j];
- idx2[j] = idx2[j+1];
- idx2[j+1] = tmp;
- swapped = TRUE;
- }
- }
- }
+ /* Build an index for each type so the names are sorted */
+ if (NULL==(idx1 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(intn))) ||
+ NULL==(idx2 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(intn)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0,
+ "memory allocation failed");
+ }
+ for (i=0; i<dt1->u.enumer.nmembs; i++)
+ idx1[i] = idx2[i] = i;
+ for (i=dt1->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
+ for (j=0, swapped=FALSE; j<i; j++) {
+ if (HDstrcmp(dt1->u.enumer.name[idx1[j]],
+ dt1->u.enumer.name[idx1[j+1]]) > 0) {
+ tmp = idx1[j];
+ idx1[j] = idx1[j+1];
+ idx1[j+1] = tmp;
+ swapped = TRUE;
+ }
+ }
+ }
+ for (i=dt2->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
+ for (j=0, swapped=FALSE; j<i; j++) {
+ if (HDstrcmp(dt2->u.enumer.name[idx2[j]],
+ dt2->u.enumer.name[idx2[j+1]]) > 0) {
+ tmp = idx2[j];
+ idx2[j] = idx2[j+1];
+ idx2[j+1] = tmp;
+ swapped = TRUE;
+ }
+ }
+ }
#ifdef H5T_DEBUG
- /* I don't quite trust the code above yet :-) --RPM */
- for (i=0; i<dt1->u.enumer.nmembs-1; i++) {
- assert(HDstrcmp(dt1->u.enumer.name[idx1[i]],
- dt1->u.enumer.name[idx1[i+1]]));
- assert(HDstrcmp(dt2->u.enumer.name[idx2[i]],
- dt2->u.enumer.name[idx2[i+1]]));
- }
+ /* I don't quite trust the code above yet :-) --RPM */
+ for (i=0; i<dt1->u.enumer.nmembs-1; i++) {
+ assert(HDstrcmp(dt1->u.enumer.name[idx1[i]],
+ dt1->u.enumer.name[idx1[i+1]]));
+ assert(HDstrcmp(dt2->u.enumer.name[idx2[i]],
+ dt2->u.enumer.name[idx2[i+1]]));
+ }
#endif
- /* Compare the members */
- base_size = dt1->parent->size;
- for (i=0; i<dt1->u.enumer.nmembs; i++) {
- tmp = HDstrcmp(dt1->u.enumer.name[idx1[i]],
- dt2->u.enumer.name[idx2[i]]);
- if (tmp<0) HGOTO_DONE(-1);
- if (tmp>0) HGOTO_DONE(1);
-
- tmp = HDmemcmp(dt1->u.enumer.value+idx1[i]*base_size,
- dt2->u.enumer.value+idx2[i]*base_size,
- base_size);
- if (tmp<0) HGOTO_DONE(-1);
- if (tmp>0) HGOTO_DONE(1);
- }
-
+ /* Compare the members */
+ base_size = dt1->parent->size;
+ for (i=0; i<dt1->u.enumer.nmembs; i++) {
+ tmp = HDstrcmp(dt1->u.enumer.name[idx1[i]],
+ dt2->u.enumer.name[idx2[i]]);
+ if (tmp<0) HGOTO_DONE(-1);
+ if (tmp>0) HGOTO_DONE(1);
+
+ tmp = HDmemcmp(dt1->u.enumer.value+idx1[i]*base_size,
+ dt2->u.enumer.value+idx2[i]*base_size,
+ base_size);
+ if (tmp<0) HGOTO_DONE(-1);
+ if (tmp>0) HGOTO_DONE(1);
+ }
+
} else if (H5T_VLEN==dt1->type) {
- /* Arbitrarily sort memory VL datatypes before disk datatypes */
- if (dt1->u.vlen.type==H5T_VLEN_MEMORY &&
- dt2->u.vlen.type==H5T_VLEN_DISK) {
+ assert(dt1->u.vlen.type>H5T_VLEN_BADTYPE && dt1->u.vlen.type<H5T_VLEN_MAXTYPE);
+ assert(dt2->u.vlen.type>H5T_VLEN_BADTYPE && dt2->u.vlen.type<H5T_VLEN_MAXTYPE);
+ assert(dt1->u.vlen.loc>H5T_VLEN_BADLOC && dt1->u.vlen.loc<H5T_VLEN_MAXLOC);
+ assert(dt2->u.vlen.loc>H5T_VLEN_BADLOC && dt2->u.vlen.loc<H5T_VLEN_MAXLOC);
+
+ /* Arbitrarily sort sequence VL datatypes before string VL datatypes */
+ if (dt1->u.vlen.type==H5T_VLEN_SEQUENCE &&
+ dt2->u.vlen.type==H5T_VLEN_STRING) {
+ HGOTO_DONE(-1);
+ } else if (dt1->u.vlen.type==H5T_VLEN_STRING &&
+ dt2->u.vlen.type==H5T_VLEN_SEQUENCE) {
+ HGOTO_DONE(1);
+ }
+ /* Arbitrarily sort VL datatypes in memory before disk */
+ if (dt1->u.vlen.loc==H5T_VLEN_MEMORY &&
+ dt2->u.vlen.loc==H5T_VLEN_DISK) {
HGOTO_DONE(-1);
- } else if (dt1->u.vlen.type==H5T_VLEN_DISK &&
- dt2->u.vlen.type==H5T_VLEN_MEMORY) {
+ } else if (dt1->u.vlen.loc==H5T_VLEN_DISK &&
+ dt2->u.vlen.loc==H5T_VLEN_MEMORY) {
HGOTO_DONE(1);
}
@@ -6466,9 +6513,9 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
H5T_conv_t func)
{
intn lt, rt; /*left and right edges */
- intn md; /*middle */
+ intn md; /*middle */
intn cmp; /*comparison result */
- H5T_path_t *table=NULL; /*path existing in the table */
+ H5T_path_t *table=NULL; /*path existing in the table */
H5T_path_t *path=NULL; /*new path */
H5T_path_t *ret_value=NULL; /*return value */
hid_t src_id=-1, dst_id=-1; /*src and dst type identifiers */
@@ -6482,30 +6529,29 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
* Make sure the first entry in the table is the no-op conversion path.
*/
if (0==H5T_g.npaths) {
- if (NULL==(H5T_g.path=H5MM_malloc(128*sizeof(H5T_path_t*)))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for type conversion path "
- "table");
- }
- H5T_g.apaths = 128;
- if (NULL==(H5T_g.path[0]=H5MM_calloc(sizeof(H5T_path_t)))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for no-op conversion path");
- }
- HDstrcpy(H5T_g.path[0]->name, "no-op");
- H5T_g.path[0]->func = H5T_conv_noop;
- H5T_g.path[0]->cdata.command = H5T_CONV_INIT;
- if (H5T_conv_noop(FAIL, FAIL, &(H5T_g.path[0]->cdata), 0, 0,
- NULL, NULL, H5P_DEFAULT)<0) {
+ if (NULL==(H5T_g.path=H5MM_malloc(128*sizeof(H5T_path_t*)))) {
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed for type conversion path table");
+ }
+ H5T_g.apaths = 128;
+ if (NULL==(H5T_g.path[0]=H5MM_calloc(sizeof(H5T_path_t)))) {
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed for no-op conversion path");
+ }
+ HDstrcpy(H5T_g.path[0]->name, "no-op");
+ H5T_g.path[0]->func = H5T_conv_noop;
+ H5T_g.path[0]->cdata.command = H5T_CONV_INIT;
+ if (H5T_conv_noop(FAIL, FAIL, &(H5T_g.path[0]->cdata), 0, 0,
+ NULL, NULL, H5P_DEFAULT)<0) {
#ifdef H5T_DEBUG
- if (H5DEBUG(T)) {
- fprintf(H5DEBUG(T), "H5T: unable to initialize no-op "
- "conversion function (ignored)\n");
- }
+ if (H5DEBUG(T)) {
+ fprintf(H5DEBUG(T), "H5T: unable to initialize no-op "
+ "conversion function (ignored)\n");
+ }
#endif
- H5E_clear(); /*ignore the error*/
- }
- H5T_g.npaths = 1;
+ H5E_clear(); /*ignore the error*/
+ }
+ H5T_g.npaths = 1;
}
/*
@@ -6518,27 +6564,28 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
* are set
*/
if (src->force_conv==FALSE && dst->force_conv==FALSE && 0==H5T_cmp(src, dst)) {
- table = H5T_g.path[0];
- cmp = 0;
- md = 0;
+ table = H5T_g.path[0];
+ cmp = 0;
+ md = 0;
} else {
- lt = md = 1;
- rt = H5T_g.npaths;
- cmp = -1;
-
- while (cmp && lt<rt) {
- md = (lt+rt) / 2;
- assert(H5T_g.path[md]);
- cmp = H5T_cmp(src, H5T_g.path[md]->src);
- if (0==cmp) cmp = H5T_cmp(dst, H5T_g.path[md]->dst);
- if (cmp<0) {
- rt = md;
- } else if (cmp>0) {
- lt = md+1;
- } else {
- table = H5T_g.path[md];
- }
- }
+ lt = md = 1;
+ rt = H5T_g.npaths;
+ cmp = -1;
+
+ while (cmp && lt<rt) {
+ md = (lt+rt) / 2;
+ assert(H5T_g.path[md]);
+ cmp = H5T_cmp(src, H5T_g.path[md]->src);
+ if (0==cmp)
+ cmp = H5T_cmp(dst, H5T_g.path[md]->dst);
+ if (cmp<0) {
+ rt = md;
+ } else if (cmp>0) {
+ lt = md+1;
+ } else {
+ table = H5T_g.path[md];
+ }
+ }
}
/*
@@ -6547,23 +6594,23 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
* the path.
*/
if (!table || func) {
- if (NULL==(path=H5MM_calloc(sizeof(H5T_path_t)))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for type conversion path");
- }
- if (name && *name) {
- strncpy(path->name, name, H5T_NAMELEN);
- path->name[H5T_NAMELEN-1] = '\0';
- } else {
- strcpy(path->name, "NONAME");
- }
- if ((src && NULL==(path->src=H5T_copy(src, H5T_COPY_ALL))) ||
- (dst && NULL==(path->dst=H5T_copy(dst, H5T_COPY_ALL)))) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
- "unable to copy data type for conversion path");
- }
+ if (NULL==(path=H5MM_calloc(sizeof(H5T_path_t)))) {
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed for type conversion path");
+ }
+ if (name && *name) {
+ strncpy(path->name, name, H5T_NAMELEN);
+ path->name[H5T_NAMELEN-1] = '\0';
+ } else {
+ strcpy(path->name, "NONAME");
+ }
+ if ((src && NULL==(path->src=H5T_copy(src, H5T_COPY_ALL))) ||
+ (dst && NULL==(path->dst=H5T_copy(dst, H5T_COPY_ALL)))) {
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
+ "unable to copy data type for conversion path");
+ }
} else {
- path = table;
+ path = table;
}
/*
@@ -6571,31 +6618,30 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
* path then add it to the path and initialize its conversion data.
*/
if (func) {
- assert(path!=table);
- assert(NULL==path->func);
- if (path->src && (src_id=H5I_register(H5I_DATATYPE,
- H5T_copy(path->src,
- H5T_COPY_ALL)))<0) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
- "unable to register source conversion type for query");
- }
- if (path->dst && (dst_id=H5I_register(H5I_DATATYPE,
- H5T_copy(path->dst,
- H5T_COPY_ALL)))<0) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
- "unable to register destination conversion type for "
- "query");
- }
- path->cdata.command = H5T_CONV_INIT;
- if ((func)(src_id, dst_id, &(path->cdata), 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
- "unable to initialize conversion function");
- }
- if (src_id>=0) H5I_dec_ref(src_id);
- if (dst_id>=0) H5I_dec_ref(dst_id);
- src_id = dst_id = -1;
- path->func = func;
- path->is_hard = TRUE;
+ assert(path!=table);
+ assert(NULL==path->func);
+ if (path->src && (src_id=H5I_register(H5I_DATATYPE,
+ H5T_copy(path->src, H5T_COPY_ALL)))<0) {
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
+ "unable to register source conversion type for query");
+ }
+ if (path->dst && (dst_id=H5I_register(H5I_DATATYPE,
+ H5T_copy(path->dst, H5T_COPY_ALL)))<0) {
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
+ "unable to register destination conversion type for query");
+ }
+ path->cdata.command = H5T_CONV_INIT;
+ if ((func)(src_id, dst_id, &(path->cdata), 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
+ "unable to initialize conversion function");
+ }
+ if (src_id>=0)
+ H5I_dec_ref(src_id);
+ if (dst_id>=0)
+ H5I_dec_ref(dst_id);
+ src_id = dst_id = -1;
+ path->func = func;
+ path->is_hard = TRUE;
}
/*
@@ -6606,86 +6652,91 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
*/
assert(path->func || (src && dst));
for (i=H5T_g.nsoft-1; i>=0 && !path->func; --i) {
- if (src->type!=H5T_g.soft[i].src ||
- dst->type!=H5T_g.soft[i].dst) {
- continue;
- }
- if ((src_id=H5I_register(H5I_DATATYPE,
- H5T_copy(path->src, H5T_COPY_ALL)))<0 ||
- (dst_id=H5I_register(H5I_DATATYPE,
- H5T_copy(path->dst, H5T_COPY_ALL)))<0) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
- "unable to register conversion types for query");
- }
- path->cdata.command = H5T_CONV_INIT;
- if ((H5T_g.soft[i].func) (src_id, dst_id, &(path->cdata),
- 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
- HDmemset (&(path->cdata), 0, sizeof(H5T_cdata_t));
- H5E_clear(); /*ignore the error*/
- } else {
- HDstrcpy (path->name, H5T_g.soft[i].name);
- path->func = H5T_g.soft[i].func;
- path->is_hard = FALSE;
- }
- H5I_dec_ref(src_id);
- H5I_dec_ref(dst_id);
- src_id = dst_id = -1;
+ if (src->type!=H5T_g.soft[i].src || dst->type!=H5T_g.soft[i].dst)
+ continue;
+ if ((src_id=H5I_register(H5I_DATATYPE,
+ H5T_copy(path->src, H5T_COPY_ALL)))<0 ||
+ (dst_id=H5I_register(H5I_DATATYPE,
+ H5T_copy(path->dst, H5T_COPY_ALL)))<0) {
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
+ "unable to register conversion types for query");
+ }
+ path->cdata.command = H5T_CONV_INIT;
+ if ((H5T_g.soft[i].func) (src_id, dst_id, &(path->cdata),
+ 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
+ HDmemset (&(path->cdata), 0, sizeof(H5T_cdata_t));
+ H5E_clear(); /*ignore the error*/
+ } else {
+ HDstrcpy (path->name, H5T_g.soft[i].name);
+ path->func = H5T_g.soft[i].func;
+ path->is_hard = FALSE;
+ }
+ H5I_dec_ref(src_id);
+ H5I_dec_ref(dst_id);
+ src_id = dst_id = -1;
}
if (!path->func) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
"no appropriate function for conversion path");
}
/* Replace an existing table entry or add a new entry */
if (table && path!=table) {
- assert(table==H5T_g.path[md]);
- H5T_print_stats(table, &nprint/*in,out*/);
- table->cdata.command = H5T_CONV_FREE;
- if ((table->func)(FAIL, FAIL, &(table->cdata), 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
+ assert(table==H5T_g.path[md]);
+ H5T_print_stats(table, &nprint/*in,out*/);
+ table->cdata.command = H5T_CONV_FREE;
+ if ((table->func)(FAIL, FAIL, &(table->cdata), 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
#ifdef H5T_DEBUG
- if (H5DEBUG(T)) {
- fprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free "
- "failed for %s (ignored)\n",
- (unsigned long)(path->func), path->name);
- }
+ if (H5DEBUG(T)) {
+ fprintf(H5DEBUG(T), "H5T: conversion function 0x%08lx free "
+ "failed for %s (ignored)\n",
+ (unsigned long)(path->func), path->name);
+ }
#endif
- H5E_clear(); /*ignore the failure*/
- }
- if (table->src) H5T_close(table->src);
- if (table->dst) H5T_close(table->dst);
- H5MM_xfree(table);
- table = path;
- H5T_g.path[md] = path;
+ H5E_clear(); /*ignore the failure*/
+ }
+ if (table->src)
+ H5T_close(table->src);
+ if (table->dst)
+ H5T_close(table->dst);
+ H5MM_xfree(table);
+ table = path;
+ H5T_g.path[md] = path;
} else if (path!=table) {
- assert(cmp);
+ assert(cmp);
if (H5T_g.npaths >= H5T_g.apaths) {
size_t na = MAX(128, 2 * H5T_g.apaths);
H5T_path_t **x = H5MM_realloc (H5T_g.path,
na*sizeof(H5T_path_t*));
if (!x) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
H5T_g.apaths = (intn)na;
H5T_g.path = x;
}
- if (cmp>0) md++;
+ if (cmp>0)
+ md++;
HDmemmove(H5T_g.path+md+1, H5T_g.path+md,
(H5T_g.npaths-md) * sizeof(H5T_path_t*));
H5T_g.npaths++;
- H5T_g.path[md] = path;
- table = path;
+ H5T_g.path[md] = path;
+ table = path;
}
ret_value = path;
- done:
+done:
if (!ret_value && path && path!=table) {
- if (path->src) H5T_close(path->src);
- if (path->dst) H5T_close(path->dst);
- H5MM_xfree(path);
- }
- if (src_id>=0) H5I_dec_ref(src_id);
- if (dst_id>=0) H5I_dec_ref(dst_id);
+ if (path->src)
+ H5T_close(path->src);
+ if (path->dst)
+ H5T_close(path->dst);
+ H5MM_xfree(path);
+ }
+ if (src_id>=0)
+ H5I_dec_ref(src_id);
+ if (dst_id>=0)
+ H5I_dec_ref(dst_id);
FUNC_LEAVE(ret_value);
}
@@ -6731,19 +6782,20 @@ H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts,
FUNC_ENTER(H5T_convert, FAIL);
#ifdef H5T_DEBUG
- if (H5DEBUG(T)) H5_timer_begin(&timer);
+ if (H5DEBUG(T))
+ H5_timer_begin(&timer);
#endif
tpath->cdata.command = H5T_CONV_CONV;
if ((tpath->func)(src_id, dst_id, &(tpath->cdata), nelmts, stride, buf,
bkg, dset_xfer_plist)<0) {
- HRETURN_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL,
+ HRETURN_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL,
"data type conversion failed");
}
#ifdef H5T_DEBUG
if (H5DEBUG(T)) {
- H5_timer_end(&(tpath->stats.timer), &timer);
- tpath->stats.ncalls++;
- tpath->stats.nelmts += nelmts;
+ H5_timer_end(&(tpath->stats.timer), &timer);
+ tpath->stats.ncalls++;
+ tpath->stats.nelmts += nelmts;
}
#endif
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 652e658..cf1c7d1 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -788,96 +788,96 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
FUNC_ENTER (H5T_conv_struct_init, FAIL);
if (!priv) {
- /*
- * Allocate private data structure and arrays.
- */
- if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(H5T_conv_struct_t))) ||
- NULL==(priv->src2dst=H5MM_malloc(src->u.compnd.nmembs *
- sizeof(intn))) ||
- NULL==(priv->src_memb_id=H5MM_malloc(src->u.compnd.nmembs *
- sizeof(hid_t))) ||
- NULL==(priv->dst_memb_id=H5MM_malloc(dst->u.compnd.nmembs *
- sizeof(hid_t))) ||
- NULL==(priv->memb_nelmts=H5MM_malloc(src->u.compnd.nmembs *
- sizeof(size_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
- src2dst = priv->src2dst;
-
- /*
- * Insure that members are sorted.
- */
- H5T_sort_value(src, NULL);
- H5T_sort_value(dst, NULL);
-
- /*
- * Build a mapping from source member number to destination member
- * number. If some source member is not a destination member then that
- * mapping element will be negative. Also create atoms for each
- * source and destination member data type so we can look up the
- * member data type conversion functions later.
- */
- for (i=0; i<src->u.compnd.nmembs; i++) {
- src2dst[i] = -1;
- for (j=0; j<dst->u.compnd.nmembs; j++) {
- if (!HDstrcmp (src->u.compnd.memb[i].name,
- dst->u.compnd.memb[j].name)) {
- src2dst[i] = j;
- break;
- }
- }
- if (src2dst[i]>=0) {
- type = H5T_copy (src->u.compnd.memb[i].type, H5T_COPY_ALL);
- tid = H5I_register (H5I_DATATYPE, type);
- assert (tid>=0);
- priv->src_memb_id[i] = tid;
-
- type = H5T_copy (dst->u.compnd.memb[src2dst[i]].type,
- H5T_COPY_ALL);
- tid = H5I_register (H5I_DATATYPE, type);
- assert (tid>=0);
- priv->dst_memb_id[src2dst[i]] = tid;
- }
- }
-
- /*
- * Those members which are in both the source and destination must be
- * the same size and shape arrays.
- */
- for (i=0; i<src->u.compnd.nmembs; i++) {
- if (src2dst[i]>=0) {
- H5T_cmemb_t *src_memb = src->u.compnd.memb + i;
- H5T_cmemb_t *dst_memb = dst->u.compnd.memb + src2dst[i];
- if (src_memb->ndims != dst_memb->ndims) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "source and dest members have incompatible "
- "size or shape");
- }
- for (j=0; j<src_memb->ndims; j++) {
- if (src_memb->dim[j] != dst_memb->dim[j]) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "source and dest members have "
- "incompatible size or shape");
- }
+ /*
+ * Allocate private data structure and arrays.
+ */
+ if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(H5T_conv_struct_t))) ||
+ NULL==(priv->src2dst=H5MM_malloc(src->u.compnd.nmembs *
+ sizeof(intn))) ||
+ NULL==(priv->src_memb_id=H5MM_malloc(src->u.compnd.nmembs *
+ sizeof(hid_t))) ||
+ NULL==(priv->dst_memb_id=H5MM_malloc(dst->u.compnd.nmembs *
+ sizeof(hid_t))) ||
+ NULL==(priv->memb_nelmts=H5MM_malloc(src->u.compnd.nmembs *
+ sizeof(size_t)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ src2dst = priv->src2dst;
+
+ /*
+ * Insure that members are sorted.
+ */
+ H5T_sort_value(src, NULL);
+ H5T_sort_value(dst, NULL);
+
+ /*
+ * Build a mapping from source member number to destination member
+ * number. If some source member is not a destination member then that
+ * mapping element will be negative. Also create atoms for each
+ * source and destination member data type so we can look up the
+ * member data type conversion functions later.
+ */
+ for (i=0; i<src->u.compnd.nmembs; i++) {
+ src2dst[i] = -1;
+ for (j=0; j<dst->u.compnd.nmembs; j++) {
+ if (!HDstrcmp (src->u.compnd.memb[i].name,
+ dst->u.compnd.memb[j].name)) {
+ src2dst[i] = j;
+ break;
+ }
+ }
+ if (src2dst[i]>=0) {
+ type = H5T_copy (src->u.compnd.memb[i].type, H5T_COPY_ALL);
+ tid = H5I_register (H5I_DATATYPE, type);
+ assert (tid>=0);
+ priv->src_memb_id[i] = tid;
+
+ type = H5T_copy (dst->u.compnd.memb[src2dst[i]].type,
+ H5T_COPY_ALL);
+ tid = H5I_register (H5I_DATATYPE, type);
+ assert (tid>=0);
+ priv->dst_memb_id[src2dst[i]] = tid;
+ }
+ }
+
+ /*
+ * Those members which are in both the source and destination must be
+ * the same size and shape arrays.
+ */
+ for (i=0; i<src->u.compnd.nmembs; i++) {
+ if (src2dst[i]>=0) {
+ H5T_cmemb_t *src_memb = src->u.compnd.memb + i;
+ H5T_cmemb_t *dst_memb = dst->u.compnd.memb + src2dst[i];
+ if (src_memb->ndims != dst_memb->ndims) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "source and dest members have incompatible "
+ "size or shape");
+ }
+ for (j=0; j<src_memb->ndims; j++) {
+ if (src_memb->dim[j] != dst_memb->dim[j]) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "source and dest members have "
+ "incompatible size or shape");
+ }
#ifndef LATER
- /* Their permutation vectors must be equal */
- if (src_memb->perm[j]!=dst_memb->perm[j]) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "member permutations must be equal");
- }
+ /* Their permutation vectors must be equal */
+ if (src_memb->perm[j]!=dst_memb->perm[j]) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "member permutations must be equal");
+ }
#endif
- }
- }
- }
+ }
+ }
+ }
- /* Calculate number of elements of each member */
- for (i=0; i<src->u.compnd.nmembs; i++) {
- priv->memb_nelmts[i] = 1;
- for (j=0; j<src->u.compnd.memb[i].ndims; j++) {
- priv->memb_nelmts[i] *= src->u.compnd.memb[i].dim[j];
- }
- }
+ /* Calculate number of elements of each member */
+ for (i=0; i<src->u.compnd.nmembs; i++) {
+ priv->memb_nelmts[i] = 1;
+ for (j=0; j<src->u.compnd.memb[i].ndims; j++) {
+ priv->memb_nelmts[i] *= src->u.compnd.memb[i].dim[j];
+ }
+ }
}
/*
@@ -888,27 +888,26 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
H5MM_xfree(priv->memb_path);
if (NULL==(priv->memb_path=H5MM_malloc(src->u.compnd.nmembs *
sizeof(H5T_path_t*)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
for (i=0; i<src->u.compnd.nmembs; i++) {
- if (src2dst[i]>=0) {
- H5T_path_t *tpath;
- tpath = H5T_path_find(src->u.compnd.memb[i].type,
- dst->u.compnd.memb[src2dst[i]].type,
- NULL, NULL);
- if (NULL==(priv->memb_path[i] = tpath)) {
- H5MM_xfree(priv->src2dst);
- H5MM_xfree(priv->src_memb_id);
- H5MM_xfree(priv->dst_memb_id);
- H5MM_xfree(priv->memb_path);
- H5MM_xfree(priv->memb_nelmts);
- cdata->priv = priv = H5MM_xfree (priv);
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unable to convert member data type");
- }
- }
+ if (src2dst[i]>=0) {
+ H5T_path_t *tpath = H5T_path_find(src->u.compnd.memb[i].type,
+ dst->u.compnd.memb[src2dst[i]].type, NULL, NULL);
+
+ if (NULL==(priv->memb_path[i] = tpath)) {
+ H5MM_xfree(priv->src2dst);
+ H5MM_xfree(priv->src_memb_id);
+ H5MM_xfree(priv->dst_memb_id);
+ H5MM_xfree(priv->memb_path);
+ H5MM_xfree(priv->memb_nelmts);
+ cdata->priv = priv = H5MM_xfree (priv);
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "unable to convert member data type");
+ }
+ }
}
cdata->need_bkg = H5T_BKG_TEMP;
@@ -968,166 +967,165 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
FUNC_ENTER (H5T_conv_struct, FAIL);
switch (cdata->command) {
- case H5T_CONV_INIT:
- /*
- * First, determine if this conversion function applies to the
- * conversion path SRC_ID-->DST_ID. If not, return failure;
- * otherwise initialize the `priv' field of `cdata' with information
- * that remains (almost) constant for this conversion path.
- */
- if (H5I_DATATYPE != H5I_get_type(src_id) ||
- NULL == (src = H5I_object(src_id)) ||
- H5I_DATATYPE != H5I_get_type(dst_id) ||
- NULL == (dst = H5I_object(dst_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
- assert (H5T_COMPOUND==src->type);
- assert (H5T_COMPOUND==dst->type);
+ case H5T_CONV_INIT:
+ /*
+ * First, determine if this conversion function applies to the
+ * conversion path SRC_ID-->DST_ID. If not, return failure;
+ * otherwise initialize the `priv' field of `cdata' with information
+ * that remains (almost) constant for this conversion path.
+ */
+ if (H5I_DATATYPE != H5I_get_type(src_id) ||
+ NULL == (src = H5I_object(src_id)) ||
+ H5I_DATATYPE != H5I_get_type(dst_id) ||
+ NULL == (dst = H5I_object(dst_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+ assert (H5T_COMPOUND==src->type);
+ assert (H5T_COMPOUND==dst->type);
- if (H5T_conv_struct_init (src, dst, cdata)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to initialize conversion data");
- }
- break;
+ if (H5T_conv_struct_init (src, dst, cdata)<0) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to initialize conversion data");
+ }
+ break;
- case H5T_CONV_FREE:
- /*
- * Free the private conversion data.
- */
- H5MM_xfree(priv->src2dst);
- H5MM_xfree(priv->src_memb_id);
- H5MM_xfree(priv->dst_memb_id);
- H5MM_xfree(priv->memb_path);
- H5MM_xfree(priv->memb_nelmts);
- cdata->priv = priv = H5MM_xfree (priv);
- break;
+ case H5T_CONV_FREE:
+ /*
+ * Free the private conversion data.
+ */
+ H5MM_xfree(priv->src2dst);
+ H5MM_xfree(priv->src_memb_id);
+ H5MM_xfree(priv->dst_memb_id);
+ H5MM_xfree(priv->memb_path);
+ H5MM_xfree(priv->memb_nelmts);
+ cdata->priv = priv = H5MM_xfree (priv);
+ break;
- case H5T_CONV_CONV:
- /*
- * Conversion.
- */
- if (H5I_DATATYPE != H5I_get_type(src_id) ||
- NULL == (src = H5I_object(src_id)) ||
- H5I_DATATYPE != H5I_get_type(dst_id) ||
- NULL == (dst = H5I_object(dst_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
- assert (priv);
- assert (bkg && cdata->need_bkg>=H5T_BKG_TEMP);
+ case H5T_CONV_CONV:
+ /*
+ * Conversion.
+ */
+ if (H5I_DATATYPE != H5I_get_type(src_id) ||
+ NULL == (src = H5I_object(src_id)) ||
+ H5I_DATATYPE != H5I_get_type(dst_id) ||
+ NULL == (dst = H5I_object(dst_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+ assert (priv);
+ assert (bkg && cdata->need_bkg>=H5T_BKG_TEMP);
- if (cdata->recalc &&
- H5T_conv_struct_init (src, dst, cdata)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to initialize conversion data");
- }
+ if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata)<0) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to initialize conversion data");
+ }
- /*
- * Insure that members are sorted.
- */
- H5T_sort_value(src, NULL);
- H5T_sort_value(dst, NULL);
- src2dst = priv->src2dst;
+ /*
+ * Insure that members are sorted.
+ */
+ H5T_sort_value(src, NULL);
+ H5T_sort_value(dst, NULL);
+ src2dst = priv->src2dst;
- /*
- * Direction of conversion.
- */
- if (stride) {
- src_delta = dst_delta = stride;
- } else if (dst->size <= src->size) {
- src_delta = src->size;
- dst_delta = dst->size;
- } else {
- src_delta = -(src->size);
- dst_delta = -(dst->size);
- buf += (nelmts-1) * src->size;
- bkg += (nelmts-1) * dst->size;
- }
+ /*
+ * Direction of conversion.
+ */
+ if (stride) {
+ src_delta = dst_delta = stride;
+ } else if (dst->size <= src->size) {
+ src_delta = src->size;
+ dst_delta = dst->size;
+ } else {
+ src_delta = -(src->size);
+ dst_delta = -(dst->size);
+ buf += (nelmts-1) * src->size;
+ bkg += (nelmts-1) * dst->size;
+ }
- for (elmtno=0; elmtno<nelmts; elmtno++) {
- /*
- * For each source member which will be present in the
- * destination, convert the member to the destination type unless
- * it is larger than the source type. Then move the member to the
- * left-most unoccupied position in the buffer. This makes the
- * data point as small as possible with all the free space on the
- * right side.
- */
- for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
- if (src2dst[i]<0) continue;
- src_memb = src->u.compnd.memb + i;
- dst_memb = dst->u.compnd.memb + src2dst[i];
-
- if (dst_memb->size <= src_memb->size) {
- if (H5T_convert(priv->memb_path[i],
- priv->src_memb_id[i],
- priv->dst_memb_id[src2dst[i]],
- priv->memb_nelmts[i],
- 0, /*no striding*/
- buf + src_memb->offset,
- bkg + dst_memb->offset,dset_xfer_plist)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to convert compound data type "
- "member");
- }
- HDmemmove (buf+offset, buf+src_memb->offset,
- dst_memb->size);
- offset += dst_memb->size;
- } else {
- HDmemmove (buf+offset, buf+src_memb->offset,
- src_memb->size);
- offset += src_memb->size;
- }
- }
+ for (elmtno=0; elmtno<nelmts; elmtno++) {
+ /*
+ * For each source member which will be present in the
+ * destination, convert the member to the destination type unless
+ * it is larger than the source type. Then move the member to the
+ * left-most unoccupied position in the buffer. This makes the
+ * data point as small as possible with all the free space on the
+ * right side.
+ */
+ for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
+ if (src2dst[i]<0)
+ continue;
+ src_memb = src->u.compnd.memb + i;
+ dst_memb = dst->u.compnd.memb + src2dst[i];
+
+ if (dst_memb->size <= src_memb->size) {
+ if (H5T_convert(priv->memb_path[i],
+ priv->src_memb_id[i],
+ priv->dst_memb_id[src2dst[i]],
+ priv->memb_nelmts[i],
+ 0, /*no striding*/
+ buf + src_memb->offset,
+ bkg + dst_memb->offset,dset_xfer_plist)<0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to convert compound data type member");
+ }
+ HDmemmove (buf+offset, buf+src_memb->offset,
+ dst_memb->size);
+ offset += dst_memb->size;
+ } else {
+ HDmemmove (buf+offset, buf+src_memb->offset,
+ src_memb->size);
+ offset += src_memb->size;
+ }
+ }
- /*
- * For each source member which will be present in the
- * destination, convert the member to the destination type if it
- * is larger than the source type (that is, has not been converted
- * yet). Then copy the member to the destination offset in the
- * background buffer.
- */
- for (i=src->u.compnd.nmembs-1; i>=0; --i) {
- if (src2dst[i]<0) continue;
- src_memb = src->u.compnd.memb + i;
- dst_memb = dst->u.compnd.memb + src2dst[i];
-
- if (dst_memb->size > src_memb->size) {
- offset -= src_memb->size;
- if (H5T_convert(priv->memb_path[i],
- priv->src_memb_id[i],
- priv->dst_memb_id[src2dst[i]],
- priv->memb_nelmts[i],
- 0, /*no striding*/
- buf+offset, bkg+dst_memb->offset,dset_xfer_plist)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to convert compound data type "
- "member");
- }
- } else {
- offset -= dst_memb->size;
- }
- HDmemmove (bkg+dst_memb->offset, buf+offset, dst_memb->size);
- }
- assert (0==offset);
+ /*
+ * For each source member which will be present in the
+ * destination, convert the member to the destination type if it
+ * is larger than the source type (that is, has not been converted
+ * yet). Then copy the member to the destination offset in the
+ * background buffer.
+ */
+ for (i=src->u.compnd.nmembs-1; i>=0; --i) {
+ if (src2dst[i]<0)
+ continue;
+ src_memb = src->u.compnd.memb + i;
+ dst_memb = dst->u.compnd.memb + src2dst[i];
+
+ if (dst_memb->size > src_memb->size) {
+ offset -= src_memb->size;
+ if (H5T_convert(priv->memb_path[i],
+ priv->src_memb_id[i],
+ priv->dst_memb_id[src2dst[i]],
+ priv->memb_nelmts[i],
+ 0, /*no striding*/
+ buf+offset, bkg+dst_memb->offset,dset_xfer_plist)<0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to convert compound data type member");
+ }
+ } else {
+ offset -= dst_memb->size;
+ }
+ HDmemmove (bkg+dst_memb->offset, buf+offset, dst_memb->size);
+ }
+ assert (0==offset);
- /*
- * Update buf and background.
- */
- buf += src_delta;
- bkg += dst_delta;
- }
+ /*
+ * Update buf and background.
+ */
+ buf += src_delta;
+ bkg += dst_delta;
+ }
- /*
- * Copy the background buffer back into the in-place conversion
- * buffer.
- */
- HDmemcpy (_buf, _bkg, nelmts*dst->size);
- break;
+ /*
+ * Copy the background buffer back into the in-place conversion
+ * buffer.
+ */
+ HDmemcpy (_buf, _bkg, nelmts*dst->size);
+ break;
- default:
- /* Some other command we don't know about yet.*/
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ default:
+ /* Some other command we don't know about yet.*/
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "unknown conversion command");
}
FUNC_LEAVE (SUCCEED);
@@ -1202,214 +1200,214 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
FUNC_ENTER (H5T_conv_struct_opt, FAIL);
switch (cdata->command) {
- case H5T_CONV_INIT:
- /*
- * First, determine if this conversion function applies to the
- * conversion path SRC_ID-->DST_ID. If not, return failure;
- * otherwise initialize the `priv' field of `cdata' with information
- * that remains (almost) constant for this conversion path.
- */
- if (H5I_DATATYPE != H5I_get_type(src_id) ||
- NULL == (src = H5I_object(src_id)) ||
- H5I_DATATYPE != H5I_get_type(dst_id) ||
- NULL == (dst = H5I_object(dst_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
- assert (H5T_COMPOUND==src->type);
- assert (H5T_COMPOUND==dst->type);
+ case H5T_CONV_INIT:
+ /*
+ * First, determine if this conversion function applies to the
+ * conversion path SRC_ID-->DST_ID. If not, return failure;
+ * otherwise initialize the `priv' field of `cdata' with information
+ * that remains (almost) constant for this conversion path.
+ */
+ if (H5I_DATATYPE != H5I_get_type(src_id) ||
+ NULL == (src = H5I_object(src_id)) ||
+ H5I_DATATYPE != H5I_get_type(dst_id) ||
+ NULL == (dst = H5I_object(dst_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+ assert (H5T_COMPOUND==src->type);
+ assert (H5T_COMPOUND==dst->type);
- /* Initialize data which is relatively constant */
- if (H5T_conv_struct_init (src, dst, cdata)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to initialize conversion data");
- }
- priv = (H5T_conv_struct_t *)(cdata->priv);
- src2dst = priv->src2dst;
-
- /*
- * If the destination type is not larger than the source type then
- * this conversion function is guaranteed to work (provided all
- * members can be converted also). Otherwise the determination is
- * quite a bit more complicated. Essentially we have to make sure
- * that there is always room in the source buffer to do the
- * conversion of a member in place. This is basically the same pair
- * of loops as in the actual conversion except it checks that there
- * is room for each conversion instead of actually doing anything.
- */
- if (dst->size > src->size) {
- for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
- if (src2dst[i]<0) continue;
- src_memb = src->u.compnd.memb + i;
- dst_memb = dst->u.compnd.memb + src2dst[i];
- src_memb_size = src_memb->size / priv->memb_nelmts[i];
- dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
- for (j=0; j<(intn)(priv->memb_nelmts[i]); j++) {
- if (dst_memb_size > src_memb_size) {
- offset += src_memb_size;
- }
- }
- }
- for (i=src->u.compnd.nmembs-1; i>=0; --i) {
- if (src2dst[i]<0) continue;
- src_memb = src->u.compnd.memb + i;
- dst_memb = dst->u.compnd.memb + src2dst[i];
- src_memb_size = src_memb->size / priv->memb_nelmts[i];
- dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
-
- for (j=priv->memb_nelmts[i]-1; j>=0; --j) {
- if (dst_memb_size > src_memb_size) {
- offset -= src_memb_size;
- if (dst_memb_size > src->size-offset) {
- H5MM_xfree(priv->src2dst);
- H5MM_xfree(priv->src_memb_id);
- H5MM_xfree(priv->dst_memb_id);
- H5MM_xfree(priv->memb_path);
- H5MM_xfree(priv->memb_nelmts);
- cdata->priv = priv = H5MM_xfree (priv);
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "convertion is unsupported by this "
- "function");
- }
- }
- }
- }
- }
- break;
+ /* Initialize data which is relatively constant */
+ if (H5T_conv_struct_init (src, dst, cdata)<0) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to initialize conversion data");
+ }
+ priv = (H5T_conv_struct_t *)(cdata->priv);
+ src2dst = priv->src2dst;
+
+ /*
+ * If the destination type is not larger than the source type then
+ * this conversion function is guaranteed to work (provided all
+ * members can be converted also). Otherwise the determination is
+ * quite a bit more complicated. Essentially we have to make sure
+ * that there is always room in the source buffer to do the
+ * conversion of a member in place. This is basically the same pair
+ * of loops as in the actual conversion except it checks that there
+ * is room for each conversion instead of actually doing anything.
+ */
+ if (dst->size > src->size) {
+ for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
+ if (src2dst[i]<0)
+ continue;
+ src_memb = src->u.compnd.memb + i;
+ dst_memb = dst->u.compnd.memb + src2dst[i];
+ src_memb_size = src_memb->size / priv->memb_nelmts[i];
+ dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
+ for (j=0; j<(intn)(priv->memb_nelmts[i]); j++) {
+ if (dst_memb_size > src_memb_size)
+ offset += src_memb_size;
+ }
+ }
+ for (i=src->u.compnd.nmembs-1; i>=0; --i) {
+ if (src2dst[i]<0)
+ continue;
+ src_memb = src->u.compnd.memb + i;
+ dst_memb = dst->u.compnd.memb + src2dst[i];
+ src_memb_size = src_memb->size / priv->memb_nelmts[i];
+ dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
+
+ for (j=(intn)(priv->memb_nelmts[i]-1); j>=0; --j) {
+ if (dst_memb_size > src_memb_size) {
+ offset -= src_memb_size;
+ if (dst_memb_size > src->size-offset) {
+ H5MM_xfree(priv->src2dst);
+ H5MM_xfree(priv->src_memb_id);
+ H5MM_xfree(priv->dst_memb_id);
+ H5MM_xfree(priv->memb_path);
+ H5MM_xfree(priv->memb_nelmts);
+ cdata->priv = priv = H5MM_xfree (priv);
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "convertion is unsupported by this "
+ "function");
+ }
+ }
+ }
+ }
+ }
+ break;
- case H5T_CONV_FREE:
- /*
- * Free the private conversion data.
- */
- priv = (H5T_conv_struct_t *)(cdata->priv);
- H5MM_xfree(priv->src2dst);
- H5MM_xfree(priv->src_memb_id);
- H5MM_xfree(priv->dst_memb_id);
- H5MM_xfree(priv->memb_path);
- H5MM_xfree(priv->memb_nelmts);
- cdata->priv = priv = H5MM_xfree (priv);
- break;
+ case H5T_CONV_FREE:
+ /*
+ * Free the private conversion data.
+ */
+ priv = (H5T_conv_struct_t *)(cdata->priv);
+ H5MM_xfree(priv->src2dst);
+ H5MM_xfree(priv->src_memb_id);
+ H5MM_xfree(priv->dst_memb_id);
+ H5MM_xfree(priv->memb_path);
+ H5MM_xfree(priv->memb_nelmts);
+ cdata->priv = priv = H5MM_xfree (priv);
+ break;
- case H5T_CONV_CONV:
- /*
- * Conversion.
- */
- if (H5I_DATATYPE != H5I_get_type(src_id) ||
- NULL == (src = H5I_object(src_id)) ||
- H5I_DATATYPE != H5I_get_type(dst_id) ||
- NULL == (dst = H5I_object(dst_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
+ case H5T_CONV_CONV:
+ /*
+ * Conversion.
+ */
+ if (H5I_DATATYPE != H5I_get_type(src_id) ||
+ NULL == (src = H5I_object(src_id)) ||
+ H5I_DATATYPE != H5I_get_type(dst_id) ||
+ NULL == (dst = H5I_object(dst_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
- /* Update cached data if necessary */
- if (cdata->recalc &&
- H5T_conv_struct_init (src, dst, cdata)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to initialize conversion data");
- }
- priv = (H5T_conv_struct_t *)(cdata->priv);
- src2dst = priv->src2dst;
- assert(priv);
- assert(bkg && cdata->need_bkg>=H5T_BKG_TEMP);
+ /* Update cached data if necessary */
+ if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata)<0) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to initialize conversion data");
+ }
+ priv = (H5T_conv_struct_t *)(cdata->priv);
+ src2dst = priv->src2dst;
+ assert(priv);
+ assert(bkg && cdata->need_bkg>=H5T_BKG_TEMP);
- /*
- * Insure that members are sorted.
- */
- H5T_sort_value(src, NULL);
- H5T_sort_value(dst, NULL);
+ /*
+ * Insure that members are sorted.
+ */
+ H5T_sort_value(src, NULL);
+ H5T_sort_value(dst, NULL);
- /*
- * For each member where the destination is not larger than the
- * source, stride through all the elements converting only that member
- * in each element and then copying the element to its final
- * destination in the bkg buffer. Otherwise move the element as far
- * left as possible in the buffer.
- */
- for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
- if (src2dst[i]<0) continue;
- src_memb = src->u.compnd.memb + i;
- dst_memb = dst->u.compnd.memb + src2dst[i];
- src_memb_size = src_memb->size / priv->memb_nelmts[i];
- dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
-
- for (j=0; j<(intn)(priv->memb_nelmts[i]); j++) {
- if (dst_memb_size <= src_memb_size) {
- xbuf = buf + src_memb->offset + j*src_memb_size;
- xbkg = bkg + dst_memb->offset + j*dst_memb_size;
- if (H5T_convert(priv->memb_path[i],
- priv->src_memb_id[i],
- priv->dst_memb_id[src2dst[i]],
- nelmts,
- stride?stride:src->size,
- xbuf, xbkg,dset_xfer_plist)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to convert compound data "
- "type member");
- }
- for (elmtno=0; elmtno<nelmts; elmtno++) {
- HDmemmove(xbkg, xbuf, dst_memb_size);
- xbuf += stride ? stride : src->size;
- xbkg += stride ? stride : dst->size;
- }
- } else {
- for (xbuf=buf, elmtno=0; elmtno<nelmts; elmtno++) {
- HDmemmove(xbuf+offset,
- xbuf+src_memb->offset+j*src_memb_size,
- src_memb_size);
- xbuf += stride ? stride : src->size;
- }
- offset += src_memb_size;
- }
- }
- }
+ /*
+ * For each member where the destination is not larger than the
+ * source, stride through all the elements converting only that member
+ * in each element and then copying the element to its final
+ * destination in the bkg buffer. Otherwise move the element as far
+ * left as possible in the buffer.
+ */
+ for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
+ if (src2dst[i]<0)
+ continue;
+ src_memb = src->u.compnd.memb + i;
+ dst_memb = dst->u.compnd.memb + src2dst[i];
+ src_memb_size = src_memb->size / priv->memb_nelmts[i];
+ dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
+
+ for (j=0; j<(intn)(priv->memb_nelmts[i]); j++) {
+ if (dst_memb_size <= src_memb_size) {
+ xbuf = buf + src_memb->offset + j*src_memb_size;
+ xbkg = bkg + dst_memb->offset + j*dst_memb_size;
+ if (H5T_convert(priv->memb_path[i],
+ priv->src_memb_id[i],
+ priv->dst_memb_id[src2dst[i]],
+ nelmts,
+ stride?stride:src->size,
+ xbuf, xbkg,dset_xfer_plist)<0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to convert compound data "
+ "type member");
+ }
+ for (elmtno=0; elmtno<nelmts; elmtno++) {
+ HDmemmove(xbkg, xbuf, dst_memb_size);
+ xbuf += stride ? stride : src->size;
+ xbkg += stride ? stride : dst->size;
+ }
+ } else {
+ for (xbuf=buf, elmtno=0; elmtno<nelmts; elmtno++) {
+ HDmemmove(xbuf+offset,
+ xbuf+src_memb->offset+j*src_memb_size, src_memb_size);
+ xbuf += stride ? stride : src->size;
+ }
+ offset += src_memb_size;
+ }
+ }
+ }
- /*
- * Work from right to left, converting those members that weren't
- * converted in the previous loop (those members where the destination
- * is larger than the source) and them to their final position in the
- * bkg buffer.
- */
- for (i=src->u.compnd.nmembs-1; i>=0; --i) {
- if (src2dst[i]<0) continue;
- src_memb = src->u.compnd.memb + i;
- dst_memb = dst->u.compnd.memb + src2dst[i];
- src_memb_size = src_memb->size / priv->memb_nelmts[i];
- dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
-
- for (j=priv->memb_nelmts[i]-1; j>=0; --j) {
- if (dst_memb_size > src_memb_size) {
- offset -= src_memb_size;
- xbuf = buf + offset;
- xbkg = bkg + dst_memb->offset + j*dst_memb_size;
- if (H5T_convert(priv->memb_path[i],
- priv->src_memb_id[i],
- priv->dst_memb_id[src2dst[i]],
- nelmts, stride?stride:src->size,
- xbuf, xbkg, dset_xfer_plist)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to convert compound data "
- "type member");
- }
- for (elmtno=0; elmtno<nelmts; elmtno++) {
- HDmemmove(xbkg, xbuf, dst_memb_size);
- xbuf += stride ? stride : src->size;
- xbkg += stride ? stride : dst->size;
- }
- }
- }
- }
+ /*
+ * Work from right to left, converting those members that weren't
+ * converted in the previous loop (those members where the destination
+ * is larger than the source) and them to their final position in the
+ * bkg buffer.
+ */
+ for (i=src->u.compnd.nmembs-1; i>=0; --i) {
+ if (src2dst[i]<0)
+ continue;
+ src_memb = src->u.compnd.memb + i;
+ dst_memb = dst->u.compnd.memb + src2dst[i];
+ src_memb_size = src_memb->size / priv->memb_nelmts[i];
+ dst_memb_size = dst_memb->size / priv->memb_nelmts[i];
+
+ for (j=(intn)(priv->memb_nelmts[i]-1); j>=0; --j) {
+ if (dst_memb_size > src_memb_size) {
+ offset -= src_memb_size;
+ xbuf = buf + offset;
+ xbkg = bkg + dst_memb->offset + j*dst_memb_size;
+ if (H5T_convert(priv->memb_path[i],
+ priv->src_memb_id[i],
+ priv->dst_memb_id[src2dst[i]],
+ nelmts, stride?stride:src->size,
+ xbuf, xbkg, dset_xfer_plist)<0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to convert compound data type member");
+ }
+ for (elmtno=0; elmtno<nelmts; elmtno++) {
+ HDmemmove(xbkg, xbuf, dst_memb_size);
+ xbuf += stride ? stride : src->size;
+ xbkg += stride ? stride : dst->size;
+ }
+ }
+ }
+ }
- /* Move background into buffer */
- for (xbuf=buf, xbkg=bkg, elmtno=0; elmtno<nelmts; elmtno++) {
- HDmemmove(xbuf, xbkg, dst->size);
- xbuf += stride ? stride : dst->size;
- xbkg += stride ? stride : dst->size;
- }
- break;
+ /* Move background into buffer */
+ for (xbuf=buf, xbkg=bkg, elmtno=0; elmtno<nelmts; elmtno++) {
+ HDmemmove(xbuf, xbkg, dst->size);
+ xbuf += stride ? stride : dst->size;
+ xbkg += stride ? stride : dst->size;
+ }
+ break;
- default:
- /* Some other command we don't know about yet.*/
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ default:
+ /* Some other command we don't know about yet.*/
+ HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "unknown conversion command");
}
FUNC_LEAVE (SUCCEED);
@@ -1654,7 +1652,7 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
* Direction of conversion.
*/
if (stride) {
- src_delta = dst_delta = stride;
+ src_delta = dst_delta = (intn)stride;
s = d = buf;
} else if (dst->size <= src->size) {
src_delta = (int)src->size; /*overflow shouldn't be possible*/
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index 4785a41..be50a6a 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -102,6 +102,9 @@ __DLL__ H5T_t *H5T_copy(const H5T_t *old_dt, H5T_copy_t method);
__DLL__ herr_t H5T_commit(H5G_entry_t *loc, const char *name, H5T_t *type);
__DLL__ herr_t H5T_lock(H5T_t *dt, hbool_t immutable);
__DLL__ herr_t H5T_close(H5T_t *dt);
+__DLL__ herr_t H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src,
+ H5T_t *dst, H5T_conv_t func);
+__DLL__ herr_t H5T_path_force_reinit(H5T_t *dt);
__DLL__ H5T_class_t H5T_get_class(const H5T_t *dt);
__DLL__ size_t H5T_get_size(const H5T_t *dt);
__DLL__ intn H5T_cmp(const H5T_t *dt1, const H5T_t *dt2);
@@ -128,7 +131,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_loc_t loc);
+__DLL__ htri_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/H5Tvlen.c b/src/H5Tvlen.c
index c6cdd34..0e3237b 100644
--- a/src/H5Tvlen.c
+++ b/src/H5Tvlen.c
@@ -36,11 +36,15 @@ static herr_t H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_f
/*-------------------------------------------------------------------------
- * Function: H5T_vlen_set_loc
+ * Function: H5T_vlen_set_loc
*
* Purpose: Sets the location of a VL datatype to be either on disk or in memory
*
- * Return: Non-negative on success/Negative on failure
+ * 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
@@ -49,74 +53,82 @@ static herr_t H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_f
*
*-------------------------------------------------------------------------
*/
-static herr_t
+static htri_t
H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc)
{
+ htri_t ret_value = 0; /* Indicate that success, but no location change */
+
FUNC_ENTER (H5T_vlen_set_loc, FAIL);
/* check parameters */
assert(dt);
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.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");
- }
+ /* Only change the location if it's different */
+ if(loc!=dt->u.vlen.loc) {
+ /* Indicate that the location changed */
+ ret_value=TRUE;
+
+ switch(loc) {
+ case H5T_VLEN_MEMORY: /* Memory based VL datatype */
+ assert(f==NULL);
+
+ /* Mark this type as being stored in memory */
+ 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;
+ break;
+
+ case H5T_VLEN_DISK: /* Disk based VL datatype */
+ assert(f);
+
+ /* Mark this type as being stored on disk */
+ dt->u.vlen.loc=H5T_VLEN_DISK;
+
+ /*
+ * Size of element on disk is 4 bytes for the length, plus the size
+ * of an address in this file, plus 4 bytes for the size of a heap
+ * ID. Memory size is different
+ */
+ dt->size = 4 + H5F_SIZEOF_ADDR(f) + 4;
+
+ /* 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;
+
+ /* Set file ID (since this VL is on disk) */
+ dt->u.vlen.f=f;
+ break;
+
+ default:
+ HRETURN_ERROR (H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid VL datatype location");
+ } /* end switch */
+ } /* end if */
- /* Reset file ID (since this VL is in memory) */
- dt->u.vlen.f=NULL;
- break;
-
- case H5T_VLEN_DISK: /* Disk based VL datatype */
- assert(f);
-
- /* Mark this type as being stored on disk */
- dt->u.vlen.loc=H5T_VLEN_DISK;
-
- /*
- * Size of element on disk is 4 bytes for the length, plus the size
- * of an address in this file, plus 4 bytes for the size of a heap
- * ID. Memory size is different
- */
- dt->size = 4 + H5F_SIZEOF_ADDR(f) + 4;
-
- /* 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;
-
- /* Set file ID (since this VL is on disk) */
- dt->u.vlen.f=f;
- break;
-
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid VL datatype location");
- } /* end switch */
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE (ret_value);
} /* end H5T_vlen_set_loc() */
@@ -144,7 +156,7 @@ hssize_t H5T_vlen_seq_mem_getlen(H5F_t UNUSED *f, void *vl_addr)
/* check parameters */
assert(vl);
- ret_value=vl->len;
+ ret_value=(hssize_t)vl->len;
FUNC_LEAVE (ret_value);
} /* end H5T_vlen_seq_mem_getlen() */
@@ -246,7 +258,7 @@ hssize_t H5T_vlen_str_mem_getlen(H5F_t UNUSED *f, void *vl_addr)
/* check parameters */
assert(s);
- ret_value=HDstrlen(s);
+ ret_value=(hssize_t)HDstrlen(s);
FUNC_LEAVE (ret_value);
} /* end H5T_vlen_str_mem_getlen() */
@@ -593,13 +605,16 @@ done:
PURPOSE
Recursively mark any VL datatypes as on disk/in memory
USAGE
- herr_t H5T_vlen_mark(dt,f,loc)
+ htri_t H5T_vlen_mark(dt,f,loc)
H5T_t *dt; IN/OUT: Pointer to the datatype to mark
H5F_t *dt; IN: Pointer to the file the datatype is in
H5T_vlen_type_t loc IN: location of VL type
RETURNS
- SUCCEED/FAIL
+ 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
DESCRIPTION
Recursively descends any VL or compound datatypes to mark all VL datatypes
as either on disk or in memory.
@@ -608,11 +623,11 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-herr_t
+htri_t
H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc)
{
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ htri_t vlen_changed; /* Whether H5T_vlen_mark changed the type (even if the size didn't change) */
+ htri_t ret_value = 0; /* Indicate that success, but no location change */
FUNC_ENTER(H5T_vlen_mark, FAIL);
@@ -623,54 +638,63 @@ H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc)
switch(dt->type) {
/* Check each field and recurse on VL and compound ones */
case H5T_COMPOUND:
- {
- intn accum_change=0; /* Amount of change in the offset of the fields */
- size_t old_size; /* Preview size of a field */
-
- /* Sort the fields based on offsets */
- H5T_sort_value(dt,NULL);
-
- for (i=0; i<dt->u.compnd.nmembs; i++) {
- /* Apply the accumulated size change to the offset of the field */
- dt->u.compnd.memb[i].offset += accum_change;
-
- /* Recurse if it's VL or compound */
- if(dt->u.compnd.memb[i].type->type==H5T_COMPOUND || dt->u.compnd.memb[i].type->type==H5T_VLEN) {
- /* Keep the old field size for later */
- old_size=dt->u.compnd.memb[i].type->size;
-
- /* Mark the VL or compound type */
- if(H5T_vlen_mark(dt->u.compnd.memb[i].type,f,loc)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
-
- /* Check if the field changed size */
- if(old_size != dt->u.compnd.memb[i].type->size) {
- /* Adjust the size of the member */
- dt->u.compnd.memb[i].size = (dt->u.compnd.memb[i].size*dt->u.compnd.memb[i].type->size)/old_size;
-
- /* Add that change to the accumulated size change */
- accum_change += (dt->u.compnd.memb[i].type->size - (int)old_size);
+ /* Compound datatypes can't change in size if the force_conv flag is not set */
+ if(dt->force_conv) {
+ intn i; /* local counting variable */
+ intn accum_change=0; /* Amount of change in the offset of the fields */
+ size_t old_size; /* Preview size of a field */
+
+ /* Sort the fields based on offsets */
+ H5T_sort_value(dt,NULL);
+
+ for (i=0; i<dt->u.compnd.nmembs; i++) {
+ /* Apply the accumulated size change to the offset of the field */
+ dt->u.compnd.memb[i].offset += accum_change;
+
+ /* Recurse if it's VL or compound */
+ /* (If the type is compound and the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */
+ if((dt->u.compnd.memb[i].type->type==H5T_COMPOUND && dt->u.compnd.memb[i].type->force_conv) || dt->u.compnd.memb[i].type->type==H5T_VLEN) {
+ /* Keep the old field size for later */
+ old_size=dt->u.compnd.memb[i].type->size;
+
+ /* Mark the VL or compound type */
+ if((vlen_changed=H5T_vlen_mark(dt->u.compnd.memb[i].type,f,loc))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
+ if(vlen_changed>0)
+ ret_value=vlen_changed;
+
+ /* Check if the field changed size */
+ if(old_size != dt->u.compnd.memb[i].type->size) {
+ /* Adjust the size of the member */
+ dt->u.compnd.memb[i].size = (dt->u.compnd.memb[i].size*dt->u.compnd.memb[i].type->size)/old_size;
+
+ /* Add that change to the accumulated size change */
+ accum_change += (dt->u.compnd.memb[i].type->size - (int)old_size);
+ } /* end if */
} /* end if */
- } /* end if */
- } /* end for */
+ } /* end for */
- /* Apply the accumulated size change to the datatype */
- dt->size += accum_change;
-
- } /* end case */
+ /* Apply the accumulated size change to the datatype */
+ dt->size += accum_change;
+ } /* end if */
break;
/* Recurse on the VL information if it's VL or compound, then free VL sequence */
case H5T_VLEN:
/* Recurse if it's VL or compound */
- if(dt->parent->type==H5T_COMPOUND || dt->parent->type==H5T_VLEN) {
- if(H5T_vlen_mark(dt->parent,f,loc)<0)
+ /* (If the type is compound and the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */
+ if((dt->parent->type==H5T_COMPOUND && dt->parent->force_conv) || dt->parent->type==H5T_VLEN) {
+ if((vlen_changed=H5T_vlen_mark(dt->parent,f,loc))<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
+ if(vlen_changed>0)
+ ret_value=vlen_changed;
} /* end if */
/* Mark this VL sequence */
- if(H5T_vlen_set_loc(dt,f,loc)<0)
+ if((vlen_changed=H5T_vlen_set_loc(dt,f,loc))<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
+ if(vlen_changed>0)
+ ret_value=vlen_changed;
break;
default: