summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2012-09-20 16:51:32 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2012-09-20 16:51:32 (GMT)
commit6de27c149724322135ad1049e55d2b3f6245a4d7 (patch)
tree4d3df33fc9f0f01258b45d460b0479db2f481e65
parent200ff7fa830bd226b09dfb52c326054d0e019269 (diff)
downloadhdf5-6de27c149724322135ad1049e55d2b3f6245a4d7.zip
hdf5-6de27c149724322135ad1049e55d2b3f6245a4d7.tar.gz
hdf5-6de27c149724322135ad1049e55d2b3f6245a4d7.tar.bz2
[svn-r22794] Purpose:
Merge r22694 and r22700 from the trunk. These are minor fractal heap edits. Tested: jam (minor change, has baked in trunk)
-rw-r--r--src/H5HF.c14
-rw-r--r--src/H5HFman.c38
-rw-r--r--src/H5HFpkg.h2
-rw-r--r--src/H5HFtiny.c162
4 files changed, 118 insertions, 98 deletions
diff --git a/src/H5HF.c b/src/H5HF.c
index a9750c9..64e8af2 100644
--- a/src/H5HF.c
+++ b/src/H5HF.c
@@ -439,14 +439,8 @@ H5HF_get_obj_len(H5HF_t *fh, hid_t dxpl_id, const void *_id, size_t *obj_len_p)
/* Check type of object in heap */
if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
- /* Skip over the flag byte */
- id++;
-
- /* Skip over object offset */
- id += fh->hdr->heap_off_size;
-
- /* Retrieve the entry length */
- UINT64DECODE_VAR(id, *obj_len_p, fh->hdr->heap_len_size);
+ if(H5HF_man_get_obj_len(fh->hdr, id, obj_len_p) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'managed' object's length")
} /* end if */
else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
if(H5HF_huge_get_obj_len(fh->hdr, dxpl_id, id, obj_len_p) < 0)
@@ -457,8 +451,8 @@ H5HF_get_obj_len(H5HF_t *fh, hid_t dxpl_id, const void *_id, size_t *obj_len_p)
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'tiny' object's length")
} /* end if */
else {
-HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
-HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
+ HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
+ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
} /* end else */
done:
diff --git a/src/H5HFman.c b/src/H5HFman.c
index 62f5580..58e3318 100644
--- a/src/H5HFman.c
+++ b/src/H5HFman.c
@@ -218,6 +218,44 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5HF_man_get_obj_len
+ *
+ * Purpose: Get the size of a managed heap object
+ *
+ * Return: SUCCEED (Can't fail)
+ *
+ * Programmer: Dana Robinson (derobins@hdfgroup.org)
+ * August 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_man_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p)
+{
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /*
+ * Check arguments.
+ */
+ HDassert(hdr);
+ HDassert(id);
+ HDassert(obj_len_p);
+
+ /* Skip over the flag byte */
+ id++;
+
+ /* Skip over object offset */
+ id += hdr->heap_off_size;
+
+ /* Retrieve the entry length */
+ UINT64DECODE_VAR(id, *obj_len_p, hdr->heap_len_size);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5HF_man_get_obj_len() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5HF_man_op_real
*
* Purpose: Internal routine to perform an operation on a managed heap
diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h
index 498c45e..e0deca7 100644
--- a/src/H5HFpkg.h
+++ b/src/H5HFpkg.h
@@ -662,6 +662,8 @@ H5_DLL herr_t H5HF_man_dblock_dest(H5HF_direct_t *dblock);
/* Managed object routines */
H5_DLL herr_t H5HF_man_insert(H5HF_hdr_t *fh, hid_t dxpl_id, size_t obj_size,
const void *obj, void *id);
+H5_DLL herr_t H5HF_man_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id,
+ size_t *obj_len_p);
H5_DLL herr_t H5HF_man_read(H5HF_hdr_t *fh, hid_t dxpl_id, const uint8_t *id,
void *obj);
H5_DLL herr_t H5HF_man_write(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
diff --git a/src/H5HFtiny.c b/src/H5HFtiny.c
index a4cbdc1..27ab443 100644
--- a/src/H5HFtiny.c
+++ b/src/H5HFtiny.c
@@ -15,11 +15,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5HFtiny.c
- * Aug 14 2006
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Created: H5HFtiny.c
+ * Aug 14 2006
+ * Quincey Koziol <koziol@hdfgroup.org>
*
- * Purpose: Routines for "tiny" objects in fractal heap
+ * Purpose: Routines for "tiny" objects in fractal heap
*
*-------------------------------------------------------------------------
*/
@@ -28,15 +28,15 @@
/* Module Setup */
/****************/
-#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
+#define H5HF_PACKAGE /* suppress error about including H5HFpkg */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5HFpkg.h" /* Fractal heaps */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5HFpkg.h" /* Fractal heaps */
/****************/
@@ -44,11 +44,11 @@
/****************/
/* Tiny object length information */
-#define H5HF_TINY_LEN_SHORT 16 /* Max. length able to be encoded in first heap ID byte */
-#define H5HF_TINY_MASK_SHORT 0x0F /* Mask for length in first heap ID byte */
-#define H5HF_TINY_MASK_EXT 0x0FFF /* Mask for length in two heap ID bytes */
-#define H5HF_TINY_MASK_EXT_1 0x0F00 /* Mask for length in first byte of two heap ID bytes */
-#define H5HF_TINY_MASK_EXT_2 0x00FF /* Mask for length in second byte of two heap ID bytes */
+#define H5HF_TINY_LEN_SHORT 16 /* Max. length able to be encoded in first heap ID byte */
+#define H5HF_TINY_MASK_SHORT 0x0F /* Mask for length in first heap ID byte */
+#define H5HF_TINY_MASK_EXT 0x0FFF /* Mask for length in two heap ID bytes */
+#define H5HF_TINY_MASK_EXT_1 0x0F00 /* Mask for length in first byte of two heap ID bytes */
+#define H5HF_TINY_MASK_EXT_2 0x00FF /* Mask for length in second byte of two heap ID bytes */
/******************/
@@ -84,15 +84,15 @@ static herr_t H5HF_tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id,
/*-------------------------------------------------------------------------
- * Function: H5HF_tiny_init
+ * Function: H5HF_tiny_init
*
- * Purpose: Initialize information for tracking 'tiny' objects
+ * Purpose: Initialize information for tracking 'tiny' objects
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Aug 14 2006
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Aug 14 2006
*
*-------------------------------------------------------------------------
*/
@@ -131,15 +131,15 @@ H5HF_tiny_init(H5HF_hdr_t *hdr)
/*-------------------------------------------------------------------------
- * Function: H5HF_tiny_insert
+ * Function: H5HF_tiny_insert
*
- * Purpose: Pack a 'tiny' object in a heap ID
+ * Purpose: Pack a 'tiny' object in a heap ID
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Aug 14 2006
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Aug 14 2006
*
*-------------------------------------------------------------------------
*/
@@ -196,15 +196,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5HF_tiny_get_obj_len
+ * Function: H5HF_tiny_get_obj_len
*
- * Purpose: Get the size of a 'tiny' object in a fractal heap
+ * Purpose: Get the size of a 'tiny' object in a fractal heap
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Aug 14 2006
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Aug 14 2006
*
*-------------------------------------------------------------------------
*/
@@ -226,9 +226,9 @@ H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p)
if(!hdr->tiny_len_extended)
enc_obj_size = *id & H5HF_TINY_MASK_SHORT;
else
- /* (performed in this odd way to avoid compiler bug on tg-login3 with
- * gcc 3.2.2 - QAK)
- */
+ /* (performed in this odd way to avoid compiler bug on tg-login3 with
+ * gcc 3.2.2 - QAK)
+ */
enc_obj_size = *(id + 1) | ((*id & H5HF_TINY_MASK_EXT_1) << 8);
/* Set the object's length */
@@ -239,15 +239,15 @@ H5HF_tiny_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p)
/*-------------------------------------------------------------------------
- * Function: H5HF_tiny_op_real
+ * Function: H5HF_tiny_op_real
*
- * Purpose: Internal routine to perform operation on 'tiny' object
+ * Purpose: Internal routine to perform operation on 'tiny' object
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Sep 11 2006
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Sep 11 2006
*
*-------------------------------------------------------------------------
*/
@@ -266,31 +266,23 @@ H5HF_tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op,
HDassert(hdr);
HDassert(id);
HDassert(op);
-
- /* Check if 'tiny' object ID is in extended form */
- if(!hdr->tiny_len_extended) {
- /* Retrieve the object's encoded length */
- enc_obj_size = *id & H5HF_TINY_MASK_SHORT;
-
- /* Advance past flag byte(s) */
+
+ /* Get the object's encoded length */
+ /* H5HF_tiny_obj_len can't fail */
+ ret_value = H5HF_tiny_get_obj_len(hdr, id, &enc_obj_size);
+
+ /* Advance past flag byte(s) */
+ if(!hdr->tiny_len_extended)
id++;
- } /* end if */
else {
- /* Retrieve the object's encoded length */
- /* (performed in this odd way to avoid compiler bug on tg-login3 with
- * gcc 3.2.2 - QAK)
- */
- enc_obj_size = *(id + 1) | ((*id & H5HF_TINY_MASK_EXT_1) << 8);
-
- /* Advance past flag byte(s) */
- /* (performed in two steps to avoid compiler bug on tg-login3 with
- * gcc 3.2.2 - QAK)
- */
+ /* (performed in two steps to avoid compiler bug on tg-login3 with
+ * gcc 3.2.2 - QAK)
+ */
id++; id++;
- } /* end else */
+ }
/* Call the user's 'op' callback */
- if(op(id, (enc_obj_size + 1), op_data) < 0)
+ if(op(id, enc_obj_size, op_data) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "application's callback failed")
done:
@@ -299,15 +291,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5HF_tiny_read
+ * Function: H5HF_tiny_read
*
- * Purpose: Read a 'tiny' object from the heap
+ * Purpose: Read a 'tiny' object from the heap
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Aug 8 2006
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Aug 8 2006
*
*-------------------------------------------------------------------------
*/
@@ -335,15 +327,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5HF_tiny_op
+ * Function: H5HF_tiny_op
*
- * Purpose: Operate directly on a 'tiny' object
+ * Purpose: Operate directly on a 'tiny' object
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Sept 11 2006
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Sept 11 2006
*
*-------------------------------------------------------------------------
*/
@@ -372,15 +364,15 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5HF_tiny_remove
+ * Function: H5HF_tiny_remove
*
- * Purpose: Remove a 'tiny' object from the heap statistics
+ * Purpose: Remove a 'tiny' object from the heap statistics
*
- * Return: SUCCEED/FAIL
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Aug 14 2006
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Aug 14 2006
*
*-------------------------------------------------------------------------
*/
@@ -398,17 +390,12 @@ H5HF_tiny_remove(H5HF_hdr_t *hdr, const uint8_t *id)
HDassert(hdr);
HDassert(id);
- /* Check if 'tiny' object ID is in extended form */
- if(!hdr->tiny_len_extended)
- enc_obj_size = *id & H5HF_TINY_MASK_SHORT;
- else
- /* (performed in this odd way to avoid compiler bug on tg-login3 with
- * gcc 3.2.2 - QAK)
- */
- enc_obj_size = *(id + 1) | ((*id & H5HF_TINY_MASK_EXT_1) << 8);
+ /* Get the object's encoded length */
+ /* H5HF_tiny_obj_len can't fail */
+ ret_value = H5HF_tiny_get_obj_len(hdr, id, &enc_obj_size);
/* Update statistics about heap */
- hdr->tiny_size -= (enc_obj_size + 1);
+ hdr->tiny_size -= enc_obj_size;
hdr->tiny_nobjs--;
/* Mark heap header as modified */
@@ -418,4 +405,3 @@ H5HF_tiny_remove(H5HF_hdr_t *hdr, const uint8_t *id)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_tiny_remove() */
-