summaryrefslogtreecommitdiffstats
path: root/src/H5HG.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5HG.c')
-rw-r--r--src/H5HG.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/src/H5HG.c b/src/H5HG.c
index 7a90475..5b9c53c 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -293,9 +293,9 @@ done:
static size_t
H5HG_alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr)
{
- size_t idx;
- uint8_t *p;
- size_t need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size);
+ size_t idx;
+ uint8_t *p;
+ size_t need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size);
size_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -354,34 +354,35 @@ H5HG_alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr)
/* Fix the free space object */
if(need == heap->obj[0].size) {
- /*
- * All free space has been exhausted from this collection.
- */
- heap->obj[0].size = 0;
- heap->obj[0].begin = NULL;
+ /*
+ * All free space has been exhausted from this collection.
+ */
+ heap->obj[0].size = 0;
+ heap->obj[0].begin = NULL;
} /* end if */
- else if(heap->obj[0].size-need >= H5HG_SIZEOF_OBJHDR (f)) {
- /*
- * Some free space remains and it's larger than a heap object header,
- * so write the new free heap object header to the heap.
- */
- heap->obj[0].size -= need;
- heap->obj[0].begin += need;
- p = heap->obj[0].begin;
- UINT16ENCODE(p, 0); /*id*/
- UINT16ENCODE(p, 0); /*nrefs*/
- UINT32ENCODE(p, 0); /*reserved*/
- H5F_ENCODE_LENGTH (f, p, heap->obj[0].size);
- assert(H5HG_ISALIGNED(heap->obj[0].size));
+ //else if(heap->obj[0].size - need >= H5HG_SIZEOF_OBJHDR(f)) {
+ else if(heap->obj[0].size >= need + H5HG_SIZEOF_OBJHDR(f)) {
+ /*
+ * Some free space remains and it's larger than a heap object header,
+ * so write the new free heap object header to the heap.
+ */
+ heap->obj[0].size -= need;
+ heap->obj[0].begin += need;
+ p = heap->obj[0].begin;
+ UINT16ENCODE(p, 0); /*id*/
+ UINT16ENCODE(p, 0); /*nrefs*/
+ UINT32ENCODE(p, 0); /*reserved*/
+ H5F_ENCODE_LENGTH (f, p, heap->obj[0].size);
+ HDassert(H5HG_ISALIGNED(heap->obj[0].size));
} /* end else-if */
else {
- /*
- * Some free space remains but it's smaller than a heap object header,
- * so we don't write the header.
- */
- heap->obj[0].size -= need;
- heap->obj[0].begin += need;
- assert(H5HG_ISALIGNED(heap->obj[0].size));
+ /*
+ * Some free space remains but it's smaller than a heap object header,
+ * so we don't write the header.
+ */
+ heap->obj[0].size -= need;
+ heap->obj[0].begin += need;
+ HDassert(H5HG_ISALIGNED(heap->obj[0].size));
}
/* Mark the heap as dirty */
@@ -739,10 +740,10 @@ done:
herr_t
H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
{
- H5HG_heap_t *heap = NULL;
- uint8_t *p = NULL, *obj_start = NULL;
- size_t need;
- unsigned u;
+ H5HG_heap_t *heap = NULL;
+ uint8_t *p = NULL, *obj_start = NULL;
+ size_t need;
+ unsigned u;
unsigned flags = H5AC__NO_FLAGS_SET;/* Whether the heap gets deleted */
herr_t ret_value = SUCCEED; /* Return value */
@@ -775,9 +776,8 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
} /* end if */
else
heap->obj[0].size += need;
- HDmemmove(obj_start, obj_start + need,
- heap->size - ((obj_start + need) - heap->chunk));
- if(heap->obj[0].size >= H5HG_SIZEOF_OBJHDR(f)) {
+ HDmemmove(obj_start, obj_start + need, heap->size - ((obj_start + need) - heap->chunk));
+ if(heap->obj[0].size >= (size_t)H5HG_SIZEOF_OBJHDR(f)) {
p = heap->obj[0].begin;
UINT16ENCODE(p, 0); /*id*/
UINT16ENCODE(p, 0); /*nrefs*/