summaryrefslogtreecommitdiffstats
path: root/src/H5HFtiny.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-09-11 17:25:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-09-11 17:25:26 (GMT)
commite5cad0ef24543e55d164a26dd42a0cc1ba5c2cbe (patch)
tree0a33a38538477c1705f93a0b92a2ba84828ff6f4 /src/H5HFtiny.c
parent9e158b781668387bf82fbab9d60ece304f0e9729 (diff)
downloadhdf5-e5cad0ef24543e55d164a26dd42a0cc1ba5c2cbe.zip
hdf5-e5cad0ef24543e55d164a26dd42a0cc1ba5c2cbe.tar.gz
hdf5-e5cad0ef24543e55d164a26dd42a0cc1ba5c2cbe.tar.bz2
[svn-r12655] Description:
Add "op" routine to perform operation on heap object "in situ", to allow for faster operations on dense links during B-tree traversal & lookup. Refactor the "read" routine to use the internal version of the "op" routine, to keep the code duplication as low as possible. Tested on: Mac OS X.4/PPC (amazon) Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5HFtiny.c')
-rw-r--r--src/H5HFtiny.c99
1 files changed, 89 insertions, 10 deletions
diff --git a/src/H5HFtiny.c b/src/H5HFtiny.c
index bcbe0eb..e1ce68c 100644
--- a/src/H5HFtiny.c
+++ b/src/H5HFtiny.c
@@ -63,6 +63,8 @@
/********************/
/* Local Prototypes */
/********************/
+static herr_t H5HF_tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id,
+ H5HF_operator_t op, void *op_data);
/*********************/
@@ -233,31 +235,33 @@ H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p)
/*-------------------------------------------------------------------------
- * Function: H5HF_tiny_read
+ * Function: H5HF_tiny_op_real
*
- * Purpose: Read a 'tiny' object from the heap
+ * Purpose: Internal routine to perform operation on 'tiny' object
*
* Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
* koziol@hdfgroup.org
- * Aug 8 2006
+ * Sep 11 2006
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5HF_tiny_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj)
+static herr_t
+H5HF_tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op,
+ void *op_data)
{
- size_t enc_obj_size; /* Encoded object size */
+ size_t enc_obj_size; /* Encoded object size */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_tiny_read)
+ FUNC_ENTER_NOAPI_NOINIT(H5HF_tiny_op_real)
/*
* Check arguments.
*/
HDassert(hdr);
HDassert(id);
- HDassert(obj);
+ HDassert(op);
/* Check if 'tiny' object ID is in extended form */
if(!hdr->tiny_len_extended) {
@@ -281,14 +285,89 @@ H5HF_tiny_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj)
id++; id++;
} /* end else */
- /* Retrieve the object's data */
- HDmemcpy(obj, id, (enc_obj_size + 1));
+ /* Call the user's 'op' callback */
+ if(op(id, (enc_obj_size + 1), op_data) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "application's callback failed")
+done:
FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5HF_tiny_op_real() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_tiny_read
+ *
+ * Purpose: Read a 'tiny' object from the heap
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Aug 8 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_tiny_read(H5HF_hdr_t *hdr, const uint8_t *id, void *obj)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5HF_tiny_read)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(hdr);
+ HDassert(id);
+ HDassert(obj);
+
+ /* Call the internal 'op' routine */
+ if(H5HF_tiny_op_real(hdr, id, H5HF_op_memcpy, obj) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_tiny_read() */
/*-------------------------------------------------------------------------
+ * Function: H5HF_tiny_op
+ *
+ * Purpose: Operate directly on a 'tiny' object
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Sept 11 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op,
+ void *op_data)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5HF_tiny_op)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(hdr);
+ HDassert(id);
+ HDassert(op);
+
+ /* Call the internal 'op' routine routine */
+ if(H5HF_tiny_op_real(hdr, id, op, op_data) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_tiny_op() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5HF_tiny_remove
*
* Purpose: Remove a 'tiny' object from the heap statistics