summaryrefslogtreecommitdiffstats
path: root/src/H5FL.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5FL.c')
-rw-r--r--src/H5FL.c203
1 files changed, 114 insertions, 89 deletions
diff --git a/src/H5FL.c b/src/H5FL.c
index 0074f6d..1d49064 100644
--- a/src/H5FL.c
+++ b/src/H5FL.c
@@ -133,20 +133,21 @@ H5FL_malloc(size_t mem_size)
{
void *ret_value=NULL; /* return value*/
- FUNC_ENTER_NOAPI(H5FL_malloc, NULL);
+ FUNC_ENTER_NOAPI(H5FL_malloc, NULL)
/* Attempt to allocate the memory requested */
if(NULL==(ret_value=H5MM_malloc(mem_size))) {
/* If we can't allocate the memory now, try garbage collecting first */
- H5FL_garbage_coll();
+ if(H5FL_garbage_coll()<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, NULL, "garbage collection failed during allocation")
/* Now try allocating the memory again */
if(NULL==(ret_value=H5MM_malloc(mem_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk")
} /* end if */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_malloc() */
@@ -172,11 +173,11 @@ H5FL_reg_init(H5FL_reg_head_t *head)
H5FL_reg_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */
herr_t ret_value=SUCCEED; /* return value*/
- FUNC_ENTER_NOAPI_NOINIT(H5FL_reg_init);
+ FUNC_ENTER_NOAPI_NOINIT(H5FL_reg_init)
/* Allocate a new garbage collection node */
if (NULL==(new_node = H5MM_malloc(sizeof(H5FL_reg_gc_node_t))))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Initialize the new garbage collection node */
new_node->list=head;
@@ -193,7 +194,7 @@ H5FL_reg_init(H5FL_reg_head_t *head)
head->size=sizeof(void *);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_reg_init() */
@@ -218,7 +219,7 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj)
H5FL_reg_node_t *temp; /* Temp. ptr to the new free list node allocated */
void *ret_value=NULL; /* Return value */
- FUNC_ENTER_NOAPI(H5FL_reg_free, NULL);
+ FUNC_ENTER_NOAPI(H5FL_reg_free, NULL)
/* Double check parameters */
assert(head);
@@ -250,14 +251,16 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj)
/* Check for exceeding free list memory use limits */
/* First check this particular list */
if(head->list_mem>H5FL_reg_lst_mem_lim)
- H5FL_reg_gc_list(head);
+ if(H5FL_reg_gc_list(head)<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, NULL, "garbage collection failed during free")
/* Then check the global amount memory on regular free lists */
if(H5FL_reg_gc_head.mem_freed>H5FL_reg_glb_mem_lim)
- H5FL_reg_gc();
+ if(H5FL_reg_gc()<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, NULL, "garbage collection failed during free")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_reg_free() */
@@ -281,14 +284,15 @@ H5FL_reg_malloc(H5FL_reg_head_t *head)
{
void *ret_value; /* Pointer to object to return */
- FUNC_ENTER_NOAPI(H5FL_reg_malloc, NULL);
+ FUNC_ENTER_NOAPI(H5FL_reg_malloc, NULL)
/* Double check parameters */
assert(head);
/* Make certain the list is initialized first */
if(!head->init)
- H5FL_reg_init(head);
+ if(H5FL_reg_init(head)<0)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'regular' blocks")
/* Check for nodes available on the free list first */
if(head->list!=NULL) {
@@ -309,14 +313,14 @@ H5FL_reg_malloc(H5FL_reg_head_t *head)
/* Otherwise allocate a node */
else {
if (NULL==(ret_value = H5FL_malloc(head->size)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Increment the number of blocks allocated in list */
head->allocated++;
} /* end else */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_reg_malloc() */
@@ -340,20 +344,20 @@ H5FL_reg_calloc(H5FL_reg_head_t *head)
{
void *ret_value; /* Pointer to object to return */
- FUNC_ENTER_NOAPI(H5FL_reg_calloc, NULL);
+ FUNC_ENTER_NOAPI(H5FL_reg_calloc, NULL)
/* Double check parameters */
assert(head);
/* Allocate the block */
if (NULL==(ret_value = H5FL_reg_malloc(head)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Clear to zeros */
HDmemset(ret_value,0,head->size);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_reg_calloc() */
@@ -379,7 +383,7 @@ H5FL_reg_gc_list(H5FL_reg_head_t *head)
void *tmp; /* Temporary node pointer */
size_t total_mem; /* Total memory used on list */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_reg_gc_list);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_reg_gc_list)
/* Calculate the total memory used on this list */
total_mem=head->onlist*head->size;
@@ -410,7 +414,7 @@ H5FL_reg_gc_list(H5FL_reg_head_t *head)
/* Decrement global count of free memory on "regular" lists */
H5FL_reg_gc_head.mem_freed-=total_mem;
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FL_reg_gc_list() */
@@ -435,14 +439,16 @@ static herr_t
H5FL_reg_gc(void)
{
H5FL_reg_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */
+ herr_t ret_value=SUCCEED; /* return value*/
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_reg_gc);
+ FUNC_ENTER_NOAPI_NOINIT(H5FL_reg_gc)
/* Walk through all the free lists, free()'ing the nodes */
gc_node=H5FL_reg_gc_head.first;
while(gc_node!=NULL) {
/* Release the free nodes on the list */
- H5FL_reg_gc_list(gc_node->list);
+ if(H5FL_reg_gc_list(gc_node->list)<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "garbage collection of list failed")
/* Go on to the next free list to garbage collect */
gc_node=gc_node->next;
@@ -451,7 +457,8 @@ H5FL_reg_gc(void)
/* Double check that all the memory on the free lists is recycled */
assert(H5FL_reg_gc_head.mem_freed==0);
- FUNC_LEAVE_NOAPI(SUCCEED);
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_reg_gc() */
@@ -486,7 +493,7 @@ H5FL_reg_term(void)
H5FL_reg_gc_node_t *left; /* pointer to garbage collection lists with work left */
H5FL_reg_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_reg_term);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_reg_term)
if (interface_initialize_g) {
/* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */
@@ -523,7 +530,7 @@ H5FL_reg_term(void)
/* Terminating this layer never affects other layers; rather, other layers affect
* the termination of this layer. */
- FUNC_LEAVE_NOAPI(0);
+ FUNC_LEAVE_NOAPI(0)
} /* end H5FL_reg_term() */
@@ -613,11 +620,11 @@ H5FL_blk_create_list(H5FL_blk_node_t **head, size_t size)
H5FL_blk_node_t *temp; /* Temp. pointer to node in the list */
H5FL_blk_node_t *ret_value;
- FUNC_ENTER_NOAPI_NOINIT(H5FL_blk_create_list);
+ FUNC_ENTER_NOAPI_NOINIT(H5FL_blk_create_list)
/* Allocate room for the new free list node */
if(NULL==(temp=H5FL_MALLOC(H5FL_blk_node_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk info");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk info")
/* Set the correct values for the new free list */
temp->size=size;
@@ -638,7 +645,7 @@ H5FL_blk_create_list(H5FL_blk_node_t **head, size_t size)
ret_value=temp;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_blk_create_list() */
@@ -664,11 +671,11 @@ H5FL_blk_init(H5FL_blk_head_t *head)
H5FL_blk_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */
herr_t ret_value=SUCCEED; /* return value*/
- FUNC_ENTER_NOAPI_NOINIT(H5FL_blk_init);
+ FUNC_ENTER_NOAPI_NOINIT(H5FL_blk_init)
/* Allocate a new garbage collection node */
if (NULL==(new_node = H5MM_malloc(sizeof(H5FL_blk_gc_node_t))))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Initialize the new garbage collection node */
new_node->pq=head;
@@ -681,7 +688,7 @@ H5FL_blk_init(H5FL_blk_head_t *head)
head->init=1;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_blk_init() */
@@ -707,7 +714,7 @@ H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size)
H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */
htri_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5FL_blk_free_block_avail, FAIL);
+ FUNC_ENTER_NOAPI(H5FL_blk_free_block_avail, FAIL)
/* Double check parameters */
assert(head);
@@ -719,7 +726,7 @@ H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size)
else
ret_value=FALSE;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_blk_free_block_avail() */
@@ -748,7 +755,7 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size)
H5FL_blk_list_t *temp; /* Temp. ptr to the new native list allocated */
void *ret_value; /* Pointer to the block to return to the user */
- FUNC_ENTER_NOAPI(H5FL_blk_malloc, NULL);
+ FUNC_ENTER_NOAPI(H5FL_blk_malloc, NULL)
/* Double check parameters */
assert(head);
@@ -756,7 +763,8 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size)
/* Make certain the list is initialized first */
if(!head->init)
- H5FL_blk_init(head);
+ if(H5FL_blk_init(head)<0)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'block' list")
/* check if there is a free list for blocks of this size */
/* and if there are any blocks available on the list */
@@ -783,7 +791,7 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size)
else {
/* Allocate new node, with room for the page info header and the actual page data */
if(NULL==(temp=H5FL_malloc(sizeof(H5FL_blk_list_t)+size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk")
/* Increment the number of blocks allocated */
head->allocated++;
@@ -796,7 +804,7 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size)
} /* end else */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_blk_malloc() */
@@ -824,7 +832,7 @@ H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size)
{
void *ret_value; /* Pointer to the block to return to the user */
- FUNC_ENTER_NOAPI(H5FL_blk_calloc, NULL);
+ FUNC_ENTER_NOAPI(H5FL_blk_calloc, NULL)
/* Double check parameters */
assert(head);
@@ -832,13 +840,13 @@ H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size)
/* Allocate the block */
if (NULL==(ret_value = H5FL_blk_malloc(head,size)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Clear the block to zeros */
HDmemset(ret_value,0,size);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_blk_calloc() */
@@ -868,14 +876,14 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block)
size_t free_size; /* Size of the block freed */
void *ret_value=NULL; /* Return value */
- FUNC_ENTER_NOAPI(H5FL_blk_free, NULL);
+ FUNC_ENTER_NOAPI(H5FL_blk_free, NULL)
/* Double check parameters */
assert(head);
assert(block);
/* Get the pointer to the native block info header in front of the native block to free */
- temp=(H5FL_blk_list_t *)((unsigned char *)block-sizeof(H5FL_blk_list_t));
+ temp=(H5FL_blk_list_t *)((unsigned char *)block-sizeof(H5FL_blk_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */
/* Save the block's size for later */
free_size=temp->size;
@@ -902,14 +910,16 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block)
/* Check for exceeding free list memory use limits */
/* First check this particular list */
if(head->list_mem>H5FL_blk_lst_mem_lim)
- H5FL_blk_gc_list(head);
+ if(H5FL_blk_gc_list(head)<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, NULL, "garbage collection failed during free")
/* Then check the global amount memory on block free lists */
if(H5FL_blk_gc_head.mem_freed>H5FL_blk_glb_mem_lim)
- H5FL_blk_gc();
+ if(H5FL_blk_gc()<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, NULL, "garbage collection failed during free")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_blk_free() */
@@ -935,7 +945,7 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size)
{
void *ret_value=NULL; /* Return value */
- FUNC_ENTER_NOAPI(H5FL_blk_realloc, NULL);
+ FUNC_ENTER_NOAPI(H5FL_blk_realloc, NULL)
/* Double check parameters */
assert(head);
@@ -946,14 +956,14 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size)
H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */
/* Get the pointer to the chunk info header in front of the chunk to free */
- temp=(H5FL_blk_list_t *)((unsigned char *)block-sizeof(H5FL_blk_list_t));
+ temp=(H5FL_blk_list_t *)((unsigned char *)block-sizeof(H5FL_blk_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */
/* check if we are actually changing the size of the buffer */
if(new_size!=temp->size) {
size_t blk_size; /* Temporary block size */
if((ret_value=H5FL_blk_malloc(head,new_size))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block")
blk_size=MIN(new_size,temp->size);
HDmemcpy(ret_value,block,blk_size);
H5FL_blk_free(head,block);
@@ -966,7 +976,7 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size)
ret_value=H5FL_blk_malloc(head,new_size);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_blk_realloc() */
@@ -992,7 +1002,7 @@ H5FL_blk_gc_list(H5FL_blk_head_t *head)
void *next; /* Temp. ptr to the free list list node */
void *temp; /* Temp. ptr to the free list page node */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_blk_gc_list);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_blk_gc_list)
/* Loop through all the nodes in the block free list queue */
while(head->head!=NULL) {
@@ -1030,7 +1040,7 @@ H5FL_blk_gc_list(H5FL_blk_head_t *head)
/* Double check that all the memory on this list is recycled */
assert(head->list_mem==0);
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FL_blk_gc_list() */
@@ -1053,14 +1063,16 @@ static herr_t
H5FL_blk_gc(void)
{
H5FL_blk_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */
+ herr_t ret_value=SUCCEED; /* return value*/
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_blk_gc);
+ FUNC_ENTER_NOAPI_NOINIT(H5FL_blk_gc)
/* Walk through all the free lists, free()'ing the nodes */
gc_node=H5FL_blk_gc_head.first;
while(gc_node!=NULL) {
/* For each free list being garbage collected, walk through the nodes and free them */
- H5FL_blk_gc_list(gc_node->pq);
+ if(H5FL_blk_gc_list(gc_node->pq)<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "garbage collection of list failed")
/* Go on to the next free list to garbage collect */
gc_node=gc_node->next;
@@ -1069,7 +1081,8 @@ H5FL_blk_gc(void)
/* Double check that all the memory on the free lists are recycled */
assert(H5FL_blk_gc_head.mem_freed==0);
- FUNC_LEAVE_NOAPI(SUCCEED);
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_blk_gc() */
@@ -1098,7 +1111,7 @@ H5FL_blk_term(void)
H5FL_blk_gc_node_t *left; /* pointer to garbage collection lists with work left */
H5FL_blk_gc_node_t *tmp; /* Temporary pointer to a garbage collection node */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_blk_term);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_blk_term)
/* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */
left=NULL;
@@ -1130,7 +1143,7 @@ printf("H5FL_blk_term: head->name=%s, head->allocated=%d\n", H5FL_blk_gc_head.fi
/* Point to the list of nodes left with allocations open, if any */
H5FL_blk_gc_head.first=left;
- FUNC_LEAVE_NOAPI(H5FL_blk_gc_head.first!=NULL ? 1 : 0);
+ FUNC_LEAVE_NOAPI(H5FL_blk_gc_head.first!=NULL ? 1 : 0)
} /* end H5FL_blk_term() */
@@ -1157,11 +1170,11 @@ H5FL_arr_init(H5FL_arr_head_t *head)
size_t u; /* Local index variable */
herr_t ret_value=SUCCEED; /* return value*/
- FUNC_ENTER_NOAPI_NOINIT(H5FL_arr_init);
+ FUNC_ENTER_NOAPI_NOINIT(H5FL_arr_init)
/* Allocate a new garbage collection node */
if (NULL==(new_node = H5MM_malloc(sizeof(H5FL_gc_arr_node_t))))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Initialize the new garbage collection node */
new_node->list=head;
@@ -1182,7 +1195,7 @@ H5FL_arr_init(H5FL_arr_head_t *head)
head->init=1;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_arr_init() */
@@ -1209,11 +1222,11 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj)
size_t free_nelem; /* Number of elements in node being free'd */
void *ret_value=NULL; /* Return value */
- FUNC_ENTER_NOAPI(H5FL_arr_free, NULL);
+ FUNC_ENTER_NOAPI(H5FL_arr_free, NULL)
/* The H5MM_xfree code allows obj to null */
if (!obj)
- HGOTO_DONE (NULL);
+ HGOTO_DONE (NULL)
/* Double check parameters */
assert(head);
@@ -1249,14 +1262,16 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj)
/* Check for exceeding free list memory use limits */
/* First check this particular list */
if(head->list_mem>H5FL_arr_lst_mem_lim)
- H5FL_arr_gc_list(head);
+ if(H5FL_arr_gc_list(head)<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, NULL, "garbage collection failed during free")
/* Then check the global amount memory on array free lists */
if(H5FL_arr_gc_head.mem_freed>H5FL_arr_glb_mem_lim)
- H5FL_arr_gc();
+ if(H5FL_arr_gc()<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, NULL, "garbage collection failed during free")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_arr_free() */
@@ -1282,7 +1297,7 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem)
void *ret_value; /* Pointer to object to return */
size_t mem_size; /* Size of memory block being recycled */
- FUNC_ENTER_NOAPI(H5FL_arr_malloc, NULL);
+ FUNC_ENTER_NOAPI(H5FL_arr_malloc, NULL)
/* Double check parameters */
assert(head);
@@ -1290,7 +1305,8 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem)
/* Make certain the list is initialized first */
if(!head->init)
- H5FL_arr_init(head);
+ if(H5FL_arr_init(head)<0)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'array' blocks")
/* Get the set of the memory block */
mem_size=head->list_arr[elem].size;
@@ -1330,7 +1346,7 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem)
ret_value=((char *)new_obj)+sizeof(H5FL_arr_list_t);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_arr_malloc() */
@@ -1354,7 +1370,7 @@ H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem)
{
void *ret_value; /* Pointer to object to return */
- FUNC_ENTER_NOAPI(H5FL_arr_calloc, NULL);
+ FUNC_ENTER_NOAPI(H5FL_arr_calloc, NULL)
/* Double check parameters */
assert(head);
@@ -1362,13 +1378,13 @@ H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem)
/* Allocate the array */
if (NULL==(ret_value = H5FL_arr_malloc(head,elem)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Clear to zeros */
HDmemset(ret_value,0,head->list_arr[elem].size);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_arr_calloc() */
@@ -1392,7 +1408,7 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem)
{
void *ret_value; /* Pointer to object to return */
- FUNC_ENTER_NOAPI(H5FL_arr_realloc, NULL);
+ FUNC_ENTER_NOAPI(H5FL_arr_realloc, NULL)
/* Double check parameters */
assert(head);
@@ -1429,7 +1445,7 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem)
} /* end else */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_arr_realloc() */
@@ -1456,7 +1472,7 @@ H5FL_arr_gc_list(H5FL_arr_head_t *head)
unsigned u; /* Counter for array of free lists */
size_t total_mem; /* Total memory used on list */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_arr_gc_list);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_arr_gc_list)
/* Walk through the array of free lists */
for(u=0; u<(unsigned)head->maxelem; u++) {
@@ -1491,7 +1507,7 @@ H5FL_arr_gc_list(H5FL_arr_head_t *head)
/* Double check that all the memory on this list is recycled */
assert(head->list_mem==0);
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FL_arr_gc_list() */
@@ -1514,14 +1530,16 @@ static herr_t
H5FL_arr_gc(void)
{
H5FL_gc_arr_node_t *gc_arr_node; /* Pointer into the list of things to garbage collect */
+ herr_t ret_value=SUCCEED; /* return value*/
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_arr_gc);
+ FUNC_ENTER_NOAPI_NOINIT(H5FL_arr_gc)
/* Walk through all the free lists, free()'ing the nodes */
gc_arr_node=H5FL_arr_gc_head.first;
while(gc_arr_node!=NULL) {
/* Release the free nodes on the list */
- H5FL_arr_gc_list(gc_arr_node->list);
+ if(H5FL_arr_gc_list(gc_arr_node->list)<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "garbage collection of list failed")
/* Go on to the next free list to garbage collect */
gc_arr_node=gc_arr_node->next;
@@ -1530,7 +1548,8 @@ H5FL_arr_gc(void)
/* Double check that all the memory on the free lists are recycled */
assert(H5FL_arr_gc_head.mem_freed==0);
- FUNC_LEAVE_NOAPI(SUCCEED);
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_arr_gc() */
@@ -1559,7 +1578,7 @@ H5FL_arr_term(void)
H5FL_gc_arr_node_t *left; /* pointer to garbage collection lists with work left */
H5FL_gc_arr_node_t *tmp; /* Temporary pointer to a garbage collection node */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_arr_term);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_arr_term)
/* Free the nodes on the garbage collection list, keeping nodes with allocations outstanding */
left=NULL;
@@ -1593,7 +1612,7 @@ printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.fi
/* Point to the list of nodes left with allocations open, if any */
H5FL_arr_gc_head.first=left;
- FUNC_LEAVE_NOAPI(H5FL_arr_gc_head.first!=NULL ? 1 : 0);
+ FUNC_LEAVE_NOAPI(H5FL_arr_gc_head.first!=NULL ? 1 : 0)
} /* end H5FL_arr_term() */
@@ -1757,18 +1776,24 @@ done:
herr_t
H5FL_garbage_coll(void)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_garbage_coll);
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI_NOINIT(H5FL_garbage_coll)
/* Garbage collect the free lists for array objects */
- H5FL_arr_gc();
+ if(H5FL_arr_gc()<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't garbage collect array objects")
/* Garbage collect free lists for blocks */
- H5FL_blk_gc();
+ if(H5FL_blk_gc()<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't garbage collect block objects")
/* Garbage collect the free lists for regular objects */
- H5FL_reg_gc();
+ if(H5FL_reg_gc()<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't garbage collect regular objects")
- FUNC_LEAVE_NOAPI(SUCCEED);
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_garbage_coll() */
@@ -1807,7 +1832,7 @@ H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_l
{
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI(H5FL_set_free_list_limits, FAIL);
+ FUNC_ENTER_NOAPI(H5FL_set_free_list_limits, FAIL)
/* Set the limit variables */
/* limit on all regular free lists */
@@ -1824,7 +1849,7 @@ H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_l
H5FL_blk_lst_mem_lim=(blk_list_lim==-1 ? UINT_MAX : (size_t)blk_list_lim);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_set_free_list_limits() */
@@ -1852,13 +1877,13 @@ H5FL_term_interface(void)
{
int ret_value=0;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_term_interface);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_term_interface)
/* Garbage collect any nodes on the free lists */
- H5FL_garbage_coll();
+ (void)H5FL_garbage_coll();
ret_value=H5FL_reg_term()+H5FL_arr_term()+H5FL_blk_term();
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}