summaryrefslogtreecommitdiffstats
path: root/src/H5P.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1999-07-03 10:31:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1999-07-03 10:31:26 (GMT)
commit650e29cff6b23b99318f70699af08cfdb57ea924 (patch)
treee37bc1ece43cbbad2504adbea63a5ef9241d2453 /src/H5P.c
parent1b20703c2048cf176df2d5c792de56da92ae03e2 (diff)
downloadhdf5-650e29cff6b23b99318f70699af08cfdb57ea924.zip
hdf5-650e29cff6b23b99318f70699af08cfdb57ea924.tar.gz
hdf5-650e29cff6b23b99318f70699af08cfdb57ea924.tar.bz2
[svn-r1418] Modified H5Tconvert to require a dataset transfer property list ID as the
final parameter (so that VL datatypes have a way to pass in the custom memory allocation routines). Fixed a conversion bug when VL fields were part of a compound datatype that was causing the no-op conversion routine to be used instead of the vlen routine. Added the H5Pset_vlen_mem_manager and H5Pget_vlen_mem_manager routines to allow users to provide their own custom memory allocation routines for VL data read in from the file and reclaimed with H5Dvlen_reclaim. Finished coding on H5Dvlen_reclaim so it works now.
Diffstat (limited to 'src/H5P.c')
-rw-r--r--src/H5P.c89
1 files changed, 88 insertions, 1 deletions
diff --git a/src/H5P.c b/src/H5P.c
index 1b46535..954cdd3 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -2722,7 +2722,7 @@ H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/)
HDmemcpy(buf, plist->fill.buf, H5T_get_size(plist->fill.type));
/* Do the conversion */
- if (H5T_convert(tpath, src_id, type_id, 1, 0, buf, bkg)<0) {
+ if (H5T_convert(tpath, src_id, type_id, 1, 0, buf, bkg, H5P_DEFAULT)<0) {
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"data type conversion failed");
}
@@ -3052,6 +3052,93 @@ H5Pget_gc_reference(hid_t fapl_id, unsigned *gc_ref/*out*/)
}
+/*-------------------------------------------------------------------------
+ * Function: H5Pset_vlen_mem_manager
+ *
+ * Purpose: Sets the memory allocate/free pair for VL datatypes. The
+ * allocation routine is called when data is read into a new array
+ * and the free routine is called when H5Dvlen_reclaim is called.
+ * The alloc_info and free_info are user parameters which are passed
+ * to the allocation and freeing functions respectively.
+ * To reset the allocate/free functions to the default setting of using
+ * the system's malloc/free functions, call this routine with alloc_func
+ * and free_func set to NULL.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, July 1, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pset_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t alloc_func,
+ void *alloc_info, H5MM_free_t free_func, void *free_info)
+{
+ H5F_xfer_t *plist = NULL;
+
+ FUNC_ENTER (H5Pset_vlen_mem_manager, FAIL);
+
+ /* Check arguments */
+ if (H5P_DATASET_XFER != H5P_get_class (plist_id) ||
+ NULL == (plist = H5I_object (plist_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
+ }
+
+ /* Update property list */
+ plist->vlen_alloc = alloc_func;
+ plist->alloc_info = alloc_info;
+ plist->vlen_free = free_func;
+ plist->free_info = free_info;
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_vlen_mem_manager
+ *
+ * Purpose: The inverse of H5Pset_vlen_mem_manager()
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, July 1, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pget_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t *alloc_func,
+ void **alloc_info, H5MM_free_t *free_func, void **free_info)
+{
+ H5F_xfer_t *plist = NULL;
+
+ FUNC_ENTER (H5Pset_vlen_mem_manager, FAIL);
+
+ /* Check arguments */
+ if (H5P_DATASET_XFER != H5P_get_class (plist_id) ||
+ NULL == (plist = H5I_object (plist_id))) {
+ HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
+ }
+
+ if(alloc_func!=NULL)
+ *alloc_func= plist->vlen_alloc;
+ if(alloc_info!=NULL)
+ *alloc_info= plist->alloc_info;
+ if(free_func!=NULL)
+ *free_func= plist->vlen_free;
+ if(free_info!=NULL)
+ *free_info= plist->free_info;
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+
+
/*--------------------------------------------------------------------------
NAME
H5Pcopy