summaryrefslogtreecommitdiffstats
path: root/src/H5Tvlen.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-06-13 01:01:46 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-06-13 01:01:46 (GMT)
commit7dfe108b5329205732ab93f494e6287cc3090f21 (patch)
tree1c7906c6461cdd2fcc18ebb1ba29217a30c0b189 /src/H5Tvlen.c
parenta3668504d93f7015661ad63c29190bceb2fd2fe4 (diff)
downloadhdf5-7dfe108b5329205732ab93f494e6287cc3090f21.zip
hdf5-7dfe108b5329205732ab93f494e6287cc3090f21.tar.gz
hdf5-7dfe108b5329205732ab93f494e6287cc3090f21.tar.bz2
[svn-r8667] Purpose:
Code optimization Description: Restructure conversion loop of variable-length objects to avoid walking through memory backwards and allocating as many temporary buffers. (This uses the optimized method used in the atomic type conversions). Also bring back another optimization for variable-length datatypes that avoids querying the DXPL so many times. Platforms tested: Solaris 2.7 (arabica) FreeBSD 4.10 (sleipnir) w/parallel Too minor to require h5committest
Diffstat (limited to 'src/H5Tvlen.c')
-rw-r--r--src/H5Tvlen.c214
1 files changed, 120 insertions, 94 deletions
diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c
index d78f4d3..3d91a57 100644
--- a/src/H5Tvlen.c
+++ b/src/H5Tvlen.c
@@ -19,6 +19,10 @@
#define H5T_PACKAGE /*suppress error about including H5Tpkg */
+/* Pablo information */
+/* (Put before include files to avoid problems with inline functions) */
+#define PABLO_MASK H5Tvlen_mask
+
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Errors */
#include "H5FLprivate.h" /* Free Lists */
@@ -28,8 +32,6 @@
#include "H5Pprivate.h" /* Property Lists */
#include "H5Tpkg.h" /* Datatypes */
-#define PABLO_MASK H5Tvlen_mask
-
/* Interface initialization */
static int interface_initialize_g = 0;
#define INTERFACE_INIT H5T_init_vlen_interface
@@ -40,21 +42,21 @@ H5FL_EXTERN(H5T_t);
/* Local functions */
static htri_t H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc);
-static herr_t H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_func, void *free_info);
+static herr_t H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, void *free_info);
static hssize_t H5T_vlen_seq_mem_getlen(void *_vl);
static htri_t H5T_vlen_seq_mem_isnull(H5F_t *f, void *_vl);
static herr_t H5T_vlen_seq_mem_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, size_t len);
-static herr_t H5T_vlen_seq_mem_write(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, void *_bg, hsize_t seq_len, hsize_t base_size);
+static herr_t H5T_vlen_seq_mem_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, hsize_t seq_len, hsize_t base_size);
static herr_t H5T_vlen_seq_mem_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg);
static hssize_t H5T_vlen_str_mem_getlen(void *_vl);
static htri_t H5T_vlen_str_mem_isnull(H5F_t *f, void *_vl);
static herr_t H5T_vlen_str_mem_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, size_t len);
-static herr_t H5T_vlen_str_mem_write(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, void *_bg, hsize_t seq_len, hsize_t base_size);
+static herr_t H5T_vlen_str_mem_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, hsize_t seq_len, hsize_t base_size);
static herr_t H5T_vlen_str_mem_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg);
static hssize_t H5T_vlen_disk_getlen(void *_vl);
static htri_t H5T_vlen_disk_isnull(H5F_t *f, void *_vl);
static herr_t H5T_vlen_disk_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, size_t len);
-static herr_t H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, void *_bg, hsize_t seq_len, hsize_t base_size);
+static herr_t H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, hsize_t seq_len, hsize_t base_size);
static herr_t H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg);
@@ -74,19 +76,19 @@ DESCRIPTION
static herr_t
H5T_init_vlen_interface(void)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_vlen_interface);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_init_vlen_interface)
- FUNC_LEAVE_NOAPI(H5T_init());
+ FUNC_LEAVE_NOAPI(H5T_init())
} /* H5T_init_vlen_interface() */
/*-------------------------------------------------------------------------
* Function: H5Tvlen_create
*
- * Purpose: Create a new variable-length data type based on the specified
+ * Purpose: Create a new variable-length datatype based on the specified
* BASE_TYPE.
*
- * Return: Success: ID of new VL data type
+ * Return: Success: ID of new VL datatype
*
* Failure: Negative
*
@@ -100,37 +102,37 @@ H5T_init_vlen_interface(void)
hid_t
H5Tvlen_create(hid_t base_id)
{
- H5T_t *base = NULL; /*base data type */
- H5T_t *dt = NULL; /*new data type */
+ H5T_t *base = NULL; /*base datatype */
+ H5T_t *dt = NULL; /*new datatype */
hid_t ret_value; /*return value */
- FUNC_ENTER_API(H5Tvlen_create, FAIL);
+ FUNC_ENTER_API(H5Tvlen_create, FAIL)
H5TRACE1("i","i",base_id);
/* Check args */
if (NULL==(base=H5I_object_verify(base_id,H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype")
/* Create up VL datatype */
if ((dt=H5T_vlen_create(base))==NULL)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location")
/* Atomize the type */
if ((ret_value=H5I_register(H5I_DATATYPE, dt))<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype")
done:
- FUNC_LEAVE_API(ret_value);
+ FUNC_LEAVE_API(ret_value)
}
/*-------------------------------------------------------------------------
* Function: H5T_vlen_create
*
- * Purpose: Create a new variable-length data type based on the specified
+ * Purpose: Create a new variable-length datatype based on the specified
* BASE_TYPE.
*
- * Return: Success: new VL data type
+ * Return: Success: new VL datatype
*
* Failure: NULL
*
@@ -142,19 +144,19 @@ done:
*-------------------------------------------------------------------------
*/
H5T_t *
-H5T_vlen_create(H5T_t *base)
+H5T_vlen_create(const H5T_t *base)
{
- H5T_t *dt = NULL; /*new VL data type */
+ H5T_t *dt = NULL; /*new VL datatype */
H5T_t *ret_value; /*return value */
- FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_create);
+ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_create)
/* Check args */
assert(base);
/* Build new type */
if (NULL==(dt = H5FL_CALLOC(H5T_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
dt->ent.header = HADDR_UNDEF;
dt->type = H5T_VLEN;
@@ -170,13 +172,13 @@ H5T_vlen_create(H5T_t *base)
/* Set up VL information */
if (H5T_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location")
/* Set return value */
ret_value=dt;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -203,7 +205,7 @@ 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_NOAPI_NOINIT(H5T_vlen_set_loc);
+ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_set_loc)
/* check parameters */
assert(dt);
@@ -275,12 +277,12 @@ H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc)
break;
default:
- HGOTO_ERROR (H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid VL datatype location");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid VL datatype location")
} /* end switch */
} /* end if */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_vlen_set_loc() */
@@ -326,6 +328,7 @@ H5T_vlen_seq_mem_getlen(void *_vl)
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static htri_t
H5T_vlen_seq_mem_isnull(H5F_t UNUSED *f, void *_vl)
{
@@ -354,6 +357,7 @@ H5T_vlen_seq_mem_isnull(H5F_t UNUSED *f, void *_vl)
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static herr_t
H5T_vlen_seq_mem_read(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void *buf, size_t len)
{
@@ -385,14 +389,12 @@ H5T_vlen_seq_mem_read(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void *bu
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static herr_t
-H5T_vlen_seq_mem_write(H5F_t UNUSED *f, hid_t dxpl_id, void *_vl, void *buf, void UNUSED *_bg, hsize_t seq_len, hsize_t base_size)
+H5T_vlen_seq_mem_write(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void UNUSED *_bg, hsize_t seq_len, hsize_t base_size)
{
- H5MM_allocate_t alloc_func; /* Vlen allocation function */
- void *alloc_info; /* Vlen allocation information */
hvl_t vl; /* Temporary hvl_t to use during operation */
size_t len;
- H5P_genplist_t *plist; /* Property list */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_seq_mem_write)
@@ -405,22 +407,13 @@ H5T_vlen_seq_mem_write(H5F_t UNUSED *f, hid_t dxpl_id, void *_vl, void *buf, voi
H5_ASSIGN_OVERFLOW(len,(seq_len*base_size),hsize_t,size_t);
/* Use the user's memory allocation routine is one is defined */
-
- /* Get the allocation function & info */
- if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
- if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,&alloc_func)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
- if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&alloc_info)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
-
- if(alloc_func!=NULL) {
- if(NULL==(vl.p=(alloc_func)(len,alloc_info)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
+ if(vl_alloc_info->alloc_func!=NULL) {
+ if(NULL==(vl.p=(vl_alloc_info->alloc_func)(len,vl_alloc_info->alloc_info)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data")
} /* end if */
else { /* Default to system malloc */
if(NULL==(vl.p=H5MM_malloc(len)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data")
} /* end else */
/* Copy the data into the newly allocated buffer */
@@ -437,7 +430,7 @@ H5T_vlen_seq_mem_write(H5F_t UNUSED *f, hid_t dxpl_id, void *_vl, void *buf, voi
HDmemcpy(_vl,&vl,sizeof(hvl_t));
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_vlen_seq_mem_write() */
@@ -519,6 +512,7 @@ H5T_vlen_str_mem_getlen(void *_vl)
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static htri_t
H5T_vlen_str_mem_isnull(H5F_t UNUSED *f, void *_vl)
{
@@ -544,6 +538,7 @@ H5T_vlen_str_mem_isnull(H5F_t UNUSED *f, void *_vl)
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static herr_t
H5T_vlen_str_mem_read(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void *buf, size_t len)
{
@@ -577,14 +572,12 @@ H5T_vlen_str_mem_read(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void *bu
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static herr_t
-H5T_vlen_str_mem_write(H5F_t UNUSED *f, hid_t dxpl_id, void *_vl, void *buf, void UNUSED *_bg, hsize_t seq_len, hsize_t base_size)
+H5T_vlen_str_mem_write(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void UNUSED *_bg, hsize_t seq_len, hsize_t base_size)
{
- H5MM_allocate_t alloc_func; /* Vlen allocation function */
- void *alloc_info; /* Vlen allocation information */
char *t; /* Pointer to temporary buffer allocated */
size_t len; /* Maximum length of the string to copy */
- H5P_genplist_t *plist; /* Property list */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_str_mem_write)
@@ -594,22 +587,13 @@ H5T_vlen_str_mem_write(H5F_t UNUSED *f, hid_t dxpl_id, void *_vl, void *buf, voi
H5_CHECK_OVERFLOW(((seq_len+1)*base_size),hsize_t,size_t);
/* Use the user's memory allocation routine if one is defined */
-
- /* Get the allocation function & info */
- if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
- if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,&alloc_func)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
- if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&alloc_info)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
-
- if(alloc_func!=NULL) {
- if(NULL==(t=(alloc_func)((size_t)((seq_len+1)*base_size),alloc_info)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
+ if(vl_alloc_info->alloc_func!=NULL) {
+ if(NULL==(t=(vl_alloc_info->alloc_func)((size_t)((seq_len+1)*base_size),vl_alloc_info->alloc_info)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data")
} /* end if */
else { /* Default to system malloc */
if(NULL==(t=H5MM_malloc((size_t)((seq_len+1)*base_size))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data")
} /* end else */
H5_ASSIGN_OVERFLOW(len,(seq_len*base_size),hsize_t,size_t);
@@ -620,7 +604,7 @@ H5T_vlen_str_mem_write(H5F_t UNUSED *f, hid_t dxpl_id, void *_vl, void *buf, voi
HDmemcpy(_vl,&t,sizeof(char *));
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value) /*lint !e429 The pointer in 't' has been copied */
} /* end H5T_vlen_str_mem_write() */
@@ -638,6 +622,7 @@ done:
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static herr_t
H5T_vlen_str_mem_setnull(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_vl, void UNUSED *_bg)
{
@@ -732,6 +717,7 @@ H5T_vlen_disk_isnull(H5F_t *f, void *_vl)
*
*-------------------------------------------------------------------------
*/
+/* ARGSUSED */
static herr_t
H5T_vlen_disk_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *buf, size_t UNUSED len)
{
@@ -785,7 +771,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, void *_vl, void *buf, void *_bg, hsize_t seq_len, hsize_t base_size)
+H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t UNUSED *vl_alloc_info, void *_vl, void *buf, void *_bg, hsize_t seq_len, hsize_t base_size)
{
uint8_t *vl=(uint8_t *)_vl; /*Pointer to the user's hvl_t information*/
uint8_t *bg=(uint8_t *)_bg; /*Pointer to the old data hvl_t */
@@ -817,7 +803,7 @@ H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, void *_vl, void *buf, void *_bg, hs
/* Free heap object */
if(H5HG_remove(f, dxpl_id, &bg_hobjid)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object")
- } /* end if */
+ } /* end if */
} /* end if */
/* Set the length of the sequence */
@@ -920,13 +906,12 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_func, void *free_info)
+H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, void *free_info)
{
- int i; /* local index variable */
- size_t j; /* local index variable */
+ unsigned i; /* local index variable */
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_reclaim_recurse);
+ FUNC_ENTER_NOAPI_NOINIT(H5T_vlen_reclaim_recurse)
assert(elem);
assert(dt);
@@ -939,17 +924,17 @@ H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_func, void *fre
void *off; /* offset of field */
/* Calculate the offset member and recurse on it */
- for(j=0; j<dt->u.array.nelem; j++) {
- off=((uint8_t *)elem)+j*(dt->parent->size);
+ for(i=0; i<dt->u.array.nelem; i++) {
+ off=((uint8_t *)elem)+i*(dt->parent->size);
if(H5T_vlen_reclaim_recurse(off,dt->parent,free_func,free_info)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free array element");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free array element")
} /* end for */
} /* end if */
break;
case H5T_COMPOUND:
/* Check each field and recurse on VL, compound, enum or array ones */
- for (i=0; i<dt->u.compnd.nmembs; i++) {
+ for (i=0; i<(unsigned)dt->u.compnd.nmembs; i++) {
/* Recurse if it's VL, compound, enum or array */
if(H5T_IS_COMPLEX(dt->u.compnd.memb[i].type->type)) {
void *off; /* offset of field */
@@ -957,7 +942,7 @@ H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_func, void *fre
/* Calculate the offset member and recurse on it */
off=((uint8_t *)elem)+dt->u.compnd.memb[i].offset;
if(H5T_vlen_reclaim_recurse(off,dt->u.compnd.memb[i].type,free_func,free_info)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free compound field");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free compound field")
} /* end if */
} /* end for */
break;
@@ -977,7 +962,7 @@ H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_func, void *fre
while(vl->len>0) {
off=((uint8_t *)vl->p)+(vl->len-1)*dt->parent->size;
if(H5T_vlen_reclaim_recurse(off,dt->parent,free_func,free_info)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free VL element");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free VL element")
vl->len--;
} /* end while */
} /* end if */
@@ -1004,7 +989,7 @@ H5T_vlen_reclaim_recurse(void *elem, H5T_t *dt, H5MM_free_t free_func, void *fre
} /* end switch */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_vlen_reclaim_recurse() */
@@ -1032,43 +1017,84 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
+/* ARGSUSED */
herr_t
H5T_vlen_reclaim(void *elem, hid_t type_id, hsize_t UNUSED ndim, hssize_t UNUSED *point, void *op_data)
{
- hid_t plist_id = *(hid_t *)op_data; /* Dataset transfer plist from iterator */
- H5MM_free_t free_func; /* Vlen free function */
- void *free_info=NULL; /* Vlen free information */
- H5T_t *dt = NULL;
- H5P_genplist_t *plist; /* Property list */
+ H5T_vlen_alloc_info_t *vl_alloc_info = (H5T_vlen_alloc_info_t *)op_data; /* VL allocation info from iterator */
+ H5T_t *dt;
herr_t ret_value;
- FUNC_ENTER_NOAPI(H5T_vlen_reclaim, FAIL);
+ FUNC_ENTER_NOAPI(H5T_vlen_reclaim, FAIL)
assert(elem);
+ assert(vl_alloc_info);
assert(H5I_DATATYPE == H5I_get_type(type_id));
/* Check args */
if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
-
- /* Get the free func & information */
- if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_XFER)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
- if (H5P_get(plist,H5D_XFER_VLEN_FREE_NAME,&free_func)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
- if (H5P_get(plist,H5D_XFER_VLEN_FREE_INFO_NAME,&free_info)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
/* Pull the free function and free info pointer out of the op_data and call the recurse datatype free function */
- ret_value=H5T_vlen_reclaim_recurse(elem,dt,free_func,free_info);
+ ret_value=H5T_vlen_reclaim_recurse(elem,dt,vl_alloc_info->free_func,vl_alloc_info->free_info);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_vlen_reclaim() */
/*--------------------------------------------------------------------------
NAME
+ H5T_vlen_get_alloc_info
+ PURPOSE
+ Retrieve allocation info for VL datatypes
+ USAGE
+ herr_t H5T_vlen_get_alloc_info(dxpl_id,vl_alloc_info)
+ hid_t dxpl_id; IN: Data transfer property list to query
+ H5T_vlen_alloc_info_t *vl_alloc_info; IN/OUT: Pointer to VL allocation information to fill
+
+ RETURNS
+ SUCCEED/FAIL
+ DESCRIPTION
+ Retrieve the VL allocation functions and information from a dataset
+ transfer property list.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5T_vlen_get_alloc_info(hid_t dxpl_id, H5T_vlen_alloc_info_t *vl_alloc_info)
+{
+ H5P_genplist_t *plist; /* DX property list */
+ herr_t ret_value=SUCCEED;
+
+ FUNC_ENTER_NOAPI(H5T_vlen_get_alloc_info, FAIL)
+
+ assert(H5I_GENPROP_LST == H5I_get_type(dxpl_id));
+ assert(vl_alloc_info);
+
+ /* Check args */
+ if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list")
+
+ /* Get the allocation functions & information */
+ if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,&vl_alloc_info->alloc_func)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value")
+ if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&vl_alloc_info->alloc_info)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value")
+ if (H5P_get(plist,H5D_XFER_VLEN_FREE_NAME,&vl_alloc_info->free_func)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value")
+ if (H5P_get(plist,H5D_XFER_VLEN_FREE_INFO_NAME,&vl_alloc_info->free_info)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_vlen_get_alloc_info() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5T_vlen_mark
PURPOSE
Recursively mark any VL datatypes as on disk/in memory