diff options
-rw-r--r-- | src/H5AC.c | 28 | ||||
-rw-r--r-- | src/H5B.c | 28 | ||||
-rw-r--r-- | src/H5FL.c | 455 | ||||
-rw-r--r-- | src/H5FLprivate.h | 87 | ||||
-rw-r--r-- | src/H5Gnode.c | 10 | ||||
-rw-r--r-- | src/H5HG.c | 8 | ||||
-rw-r--r-- | src/H5HP.c | 10 | ||||
-rw-r--r-- | src/H5O.c | 24 | ||||
-rw-r--r-- | src/H5S.c | 2 | ||||
-rw-r--r-- | src/H5Sselect.c | 91 |
10 files changed, 442 insertions, 301 deletions
@@ -131,14 +131,14 @@ static H5AC_t *current_cache_g = NULL; /*for sorting */ H5FL_DEFINE_STATIC(H5AC_t); /* Declare a PQ free list to manage the cache mapping array information */ -H5FL_ARR_DEFINE_STATIC(int,-1); +H5FL_SEQ_DEFINE_STATIC(int); /* Declare a PQ free list to manage the cache slot array information */ -H5FL_ARR_DEFINE_STATIC(H5AC_info_ptr_t,-1); +H5FL_SEQ_DEFINE_STATIC(H5AC_info_ptr_t); #ifdef H5AC_DEBUG /* Declare a PQ free list to manage the protected slot array information */ -H5FL_ARR_DEFINE_STATIC(H5AC_prot_t,-1); +H5FL_SEQ_DEFINE_STATIC(H5AC_prot_t); #endif /* H5AC_DEBUG */ @@ -371,12 +371,12 @@ H5AC_create(H5F_t *f, int size_hint) if (NULL==(f->shared->cache = cache = H5FL_CALLOC(H5AC_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); cache->nslots = size_hint; - if (NULL==( cache->slot = H5FL_ARR_CALLOC(H5AC_info_ptr_t,cache->nslots))) + if (NULL==( cache->slot = H5FL_SEQ_CALLOC(H5AC_info_ptr_t,cache->nslots))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - if (NULL==( cache->dslot = H5FL_ARR_CALLOC(H5AC_info_ptr_t,cache->nslots))) + if (NULL==( cache->dslot = H5FL_SEQ_CALLOC(H5AC_info_ptr_t,cache->nslots))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); #ifdef H5AC_DEBUG - if ((cache->prot = H5FL_ARR_CALLOC(H5AC_prot_t,cache->nslots))==NULL) + if ((cache->prot = H5FL_SEQ_CALLOC(H5AC_prot_t,cache->nslots))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); #endif /* H5AC_DEBUG */ @@ -387,12 +387,12 @@ done: if(ret_value<0) { if(cache!=NULL) { if(cache->dslot !=NULL) - cache->dslot = H5FL_ARR_FREE (H5AC_info_ptr_t,cache->dslot); + cache->dslot = H5FL_SEQ_FREE (H5AC_info_ptr_t,cache->dslot); if(cache->slot !=NULL) - cache->slot = H5FL_ARR_FREE (H5AC_info_ptr_t,cache->slot); + cache->slot = H5FL_SEQ_FREE (H5AC_info_ptr_t,cache->slot); #ifdef H5AC_DEBUG if(cache->prot !=NULL) - cache->prot = H5FL_ARR_FREE (H5AC_prot_t,cache->prot); + cache->prot = H5FL_SEQ_FREE (H5AC_prot_t,cache->prot); #endif /* H5AC_DEBUG */ f->shared->cache = H5FL_FREE (H5AC_t,f->shared->cache); } /* end if */ @@ -442,12 +442,12 @@ H5AC_dest(H5F_t *f, hid_t dxpl_id) cache->prot[i].aprots = 0; cache->prot[i].nprots = 0; } - cache->prot = H5FL_ARR_FREE(H5AC_prot_t,cache->prot); + cache->prot = H5FL_SEQ_FREE(H5AC_prot_t,cache->prot); } #endif - cache->dslot = H5FL_ARR_FREE(H5AC_info_ptr_t,cache->dslot); - cache->slot = H5FL_ARR_FREE(H5AC_info_ptr_t,cache->slot); + cache->dslot = H5FL_SEQ_FREE(H5AC_info_ptr_t,cache->dslot); + cache->slot = H5FL_SEQ_FREE(H5AC_info_ptr_t,cache->slot); cache->nslots = 0; f->shared->cache = cache = H5FL_FREE(H5AC_t,cache); @@ -787,7 +787,7 @@ H5AC_flush(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, unsi * Sort the cache entries by address since flushing them in * ascending order by address is much more efficient. */ - if (NULL==(map=H5FL_ARR_MALLOC(int,cache->nslots))) + if (NULL==(map=H5FL_SEQ_MALLOC(int,cache->nslots))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); #ifdef H5_HAVE_PARALLEL /* If MPIO, MPIPOSIX, or FPHDF5 is used, do special parallel I/O actions */ @@ -1004,7 +1004,7 @@ H5AC_flush(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, unsi done: if(map!=NULL) - map = H5FL_ARR_FREE(int,map); + map = H5FL_SEQ_FREE(int,map); FUNC_LEAVE_NOAPI(ret_value); } @@ -178,10 +178,10 @@ H5FL_BLK_DEFINE_STATIC(page); H5FL_BLK_DEFINE_STATIC(native_block); /* Declare a free list to manage the H5B_key_t array information */ -H5FL_ARR_DEFINE_STATIC(H5B_key_t,-1); +H5FL_SEQ_DEFINE_STATIC(H5B_key_t); /* Declare a free list to manage the haddr_t array information */ -H5FL_ARR_DEFINE_STATIC(haddr_t,-1); +H5FL_SEQ_DEFINE_STATIC(haddr_t); /* Declare a free list to manage the H5B_t struct */ H5FL_DEFINE_STATIC(H5B_t); @@ -251,8 +251,8 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, bt->nchildren = 0; if (NULL==(bt->page=H5FL_BLK_CALLOC(page,size)) || NULL==(bt->native=H5FL_BLK_MALLOC(native_block,total_native_keysize)) || - NULL==(bt->child=H5FL_ARR_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) || - NULL==(bt->key=H5FL_ARR_MALLOC(H5B_key_t,(size_t)(2*H5F_KVALUE(f,type)+1)))) + NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) || + NULL==(bt->key=H5FL_SEQ_MALLOC(H5B_key_t,(size_t)(2*H5F_KVALUE(f,type)+1)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node"); /* @@ -348,8 +348,8 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) bt->ndirty = 0; if (NULL==(bt->page=H5FL_BLK_MALLOC(page,size)) || NULL==(bt->native=H5FL_BLK_MALLOC(native_block,total_nkey_size)) || - NULL==(bt->key=H5FL_ARR_MALLOC(H5B_key_t,(size_t)(2*H5F_KVALUE(f,type)+1))) || - NULL==(bt->child=H5FL_ARR_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type))))) + NULL==(bt->key=H5FL_SEQ_MALLOC(H5B_key_t,(size_t)(2*H5F_KVALUE(f,type)+1))) || + NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type))))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if (H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, bt->page)<0) HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree node"); @@ -534,8 +534,8 @@ H5B_dest(H5F_t UNUSED *f, H5B_t *bt) /* Verify that node is clean */ assert(bt->cache_info.dirty==0); - H5FL_ARR_FREE(haddr_t,bt->child); - H5FL_ARR_FREE(H5B_key_t,bt->key); + H5FL_SEQ_FREE(haddr_t,bt->child); + H5FL_SEQ_FREE(H5B_key_t,bt->key); H5FL_BLK_FREE(page,bt->page); H5FL_BLK_FREE(native_block,bt->native); H5FL_FREE(H5B_t,bt); @@ -1541,7 +1541,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op * We've reached the left-most leaf. Now follow the right-sibling * pointer from leaf to leaf until we've processed all leaves. */ - if (NULL==(child=H5FL_ARR_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) || + if (NULL==(child=H5FL_SEQ_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) || NULL==(key=H5MM_malloc((2*H5F_KVALUE(f, type)+1)*type->sizeof_nkey))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); for (cur_addr=addr, ret_value=0; H5F_addr_defined(cur_addr) && !ret_value; cur_addr=next_addr) { @@ -1580,7 +1580,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op done: if(child!=NULL) - H5FL_ARR_FREE(haddr_t,child); + H5FL_SEQ_FREE(haddr_t,child); if(key!=NULL) H5MM_xfree(key); FUNC_LEAVE_NOAPI(ret_value); @@ -2150,8 +2150,8 @@ H5B_copy(H5F_t *f, const H5B_t *old_bt) if (NULL==(new_node->page=H5FL_BLK_MALLOC(page,size)) || NULL==(new_node->native=H5FL_BLK_MALLOC(native_block,total_native_keysize)) || - NULL==(new_node->child=H5FL_ARR_MALLOC(haddr_t,nkeys)) || - NULL==(new_node->key=H5FL_ARR_MALLOC(H5B_key_t,(nkeys+1)))) + NULL==(new_node->child=H5FL_SEQ_MALLOC(haddr_t,nkeys)) || + NULL==(new_node->key=H5FL_SEQ_MALLOC(H5B_key_t,(nkeys+1)))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node"); /* Copy the other structures */ @@ -2175,8 +2175,8 @@ done: if(new_node) { H5FL_BLK_FREE (page,new_node->page); H5FL_BLK_FREE (native_block,new_node->native); - H5FL_ARR_FREE (haddr_t,new_node->child); - H5FL_ARR_FREE (H5B_key_t,new_node->key); + H5FL_SEQ_FREE (haddr_t,new_node->child); + H5FL_SEQ_FREE (H5B_key_t,new_node->key); H5FL_FREE (H5B_t,new_node); } /* end if */ } /* end if */ @@ -923,8 +923,6 @@ done: void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size) { - size_t blk_size; /* Temporary block size */ - H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */ void *ret_value=NULL; /* Return value */ FUNC_ENTER_NOAPI(H5FL_blk_realloc, NULL); @@ -935,11 +933,15 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size) /* Check if we are actually re-allocating a block */ if(block!=NULL) { + 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)); /* 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"); blk_size=MIN(new_size,temp->size); @@ -1142,6 +1144,7 @@ static herr_t H5FL_arr_init(H5FL_arr_head_t *head) { H5FL_gc_arr_node_t *new_node; /* Pointer to the node for the new list to garbage collect */ + size_t u; /* Local index variable */ herr_t ret_value=SUCCEED; /* return value*/ FUNC_ENTER_NOAPI_NOINIT(H5FL_arr_init); @@ -1157,21 +1160,13 @@ H5FL_arr_init(H5FL_arr_head_t *head) new_node->next=H5FL_arr_gc_head.first; H5FL_arr_gc_head.first=new_node; - /* Allocate room for the free lists, if the arrays have a maximum size */ - if(head->maxelem>0) { - if (NULL==(head->u.list_arr = H5MM_calloc(head->maxelem*sizeof(H5FL_arr_node_t *)))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - if (NULL==(head->onlist = H5MM_calloc(head->maxelem*sizeof(unsigned)))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - } /* end if */ - else { - head->u.queue.init=0; - head->u.queue.allocated=0; - head->u.queue.onlist=0; - head->u.queue.list_mem=0; - head->u.queue.name=head->name; - head->u.queue.head=NULL; - } /* end else */ + /* Allocate room for the free lists */ + if (NULL==(head->list_arr = H5MM_calloc((size_t)head->maxelem*sizeof(H5FL_arr_node_t)))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Initialize the size of each array */ + for(u=1; u<(size_t)head->maxelem; u++) + head->list_arr[u].size=head->size*u; /* Indicate that the free list is initialized */ head->init=1; @@ -1199,7 +1194,7 @@ done: void * H5FL_arr_free(H5FL_arr_head_t *head, void *obj) { - H5FL_arr_node_t *temp; /* Temp. ptr to the new free list node allocated */ + H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ size_t mem_size; /* Size of memory being freed */ size_t free_nelem; /* Number of elements in node being free'd */ void *ret_value=NULL; /* Return value */ @@ -1216,46 +1211,39 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) /* Make certain that the free list is initialized */ assert(head->init); - /* Check if there are a maximum number of elements in list */ - if(head->maxelem>0) { - /* Get the pointer to the info header in front of the block to free */ - temp=(H5FL_arr_node_t *)((unsigned char *)obj-sizeof(H5FL_arr_node_t)); - - /* Save the number of elements for later */ - free_nelem=temp->nelem; + /* Get the pointer to the info header in front of the block to free */ + temp=(H5FL_arr_list_t *)((unsigned char *)obj-sizeof(H5FL_arr_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */ - /* Double-check that there is enough room for arrays of this size */ - assert((int)free_nelem<=head->maxelem); + /* Get the number of elements */ + free_nelem=temp->nelem; - /* Link into the free list */ - temp->next=head->u.list_arr[free_nelem]; + /* Double-check that there is enough room for arrays of this size */ + assert((int)free_nelem<=head->maxelem); - /* Point free list at the node freed */ - head->u.list_arr[free_nelem]=temp; + /* Link into the free list */ + temp->next=head->list_arr[free_nelem].list; - /* Set the amount of memory being freed */ - mem_size=free_nelem*head->size; + /* Point free list at the node freed */ + head->list_arr[free_nelem].list=temp; - /* Increment the number of blocks & memory used on free list */ - head->onlist[free_nelem]++; - head->list_mem+=mem_size; + /* Get the size of arrays with this many elements */ + mem_size=head->list_arr[free_nelem].size; - /* Increment the amount of "array" freed memory globally */ - H5FL_arr_gc_head.mem_freed+=mem_size; + /* Increment the number of blocks & memory used on free list */ + head->list_arr[free_nelem].onlist++; + head->list_mem+=mem_size; - /* 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); + /* Increment the amount of "array" freed memory globally */ + H5FL_arr_gc_head.mem_freed+=mem_size; - /* 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(); + /* 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); - } /* end if */ - /* No maximum number of elements, use block routine */ - else - H5FL_blk_free(&(head->u.queue),obj); + /* 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(); done: FUNC_LEAVE_NOAPI(ret_value); @@ -1280,7 +1268,7 @@ done: void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) { - H5FL_arr_node_t *new_obj; /* Pointer to the new free list node allocated */ + H5FL_arr_list_t *new_obj; /* Pointer to the new free list node allocated */ void *ret_value; /* Pointer to object to return */ size_t mem_size; /* Size of memory block being recycled */ @@ -1294,54 +1282,42 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) if(!head->init) H5FL_arr_init(head); - /* Set the set of the memory block */ - mem_size=head->size*elem; - - /* Check if there is a maximum number of elements in array */ - if(head->maxelem>0) { - /* Sanity check that the number of elements is supported */ - assert((int)elem<=head->maxelem); - - /* Check for nodes available on the free list first */ - if(head->u.list_arr[elem]!=NULL) { - /* Get a pointer to the block on the free list */ - new_obj=head->u.list_arr[elem]; + /* Get the set of the memory block */ + mem_size=head->list_arr[elem].size; - /* Remove node from free list */ - head->u.list_arr[elem]=head->u.list_arr[elem]->next; + /* Sanity check that the number of elements is supported */ + assert((int)elem<=head->maxelem); - /* Decrement the number of blocks & memory used on free list */ - head->onlist[elem]--; - head->list_mem-=mem_size; + /* Check for nodes available on the free list first */ + if(head->list_arr[elem].list!=NULL) { + /* Get a pointer to the block on the free list */ + new_obj=head->list_arr[elem].list; - /* Decrement the amount of global "array" free list memory in use */ - H5FL_arr_gc_head.mem_freed-=mem_size; + /* Remove node from free list */ + head->list_arr[elem].list=head->list_arr[elem].list->next; - /* Restore number of elements */ - new_obj->nelem=elem; + /* Decrement the number of blocks & memory used on free list */ + head->list_arr[elem].onlist--; + head->list_mem-=mem_size; - /* Get the pointer to the data block */ - ret_value=((char *)new_obj)+sizeof(H5FL_arr_node_t); + /* Decrement the amount of global "array" free list memory in use */ + H5FL_arr_gc_head.mem_freed-=mem_size; - } /* end if */ - /* Otherwise allocate a node */ - else { - if (NULL==(new_obj = H5FL_malloc(sizeof(H5FL_arr_node_t)+mem_size))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + } /* end if */ + /* Otherwise allocate a node */ + else { + if (NULL==(new_obj = H5FL_malloc(sizeof(H5FL_arr_list_t)+mem_size))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - /* Increment the number of blocks allocated in list */ - head->allocated++; + /* Increment the number of blocks allocated in list */ + head->allocated++; + } /* end else */ - /* Initialize the new object */ - new_obj->nelem=elem; + /* Initialize the new object */ + new_obj->nelem=elem; - /* Get a pointer to the new block */ - ret_value=((char *)new_obj)+sizeof(H5FL_arr_node_t); - } /* end else */ - } /* end if */ - /* No fixed number of elements, use PQ routine */ - else - ret_value=H5FL_blk_malloc(&(head->u.queue),mem_size); + /* Get a pointer to the new block */ + ret_value=((char *)new_obj)+sizeof(H5FL_arr_list_t); done: FUNC_LEAVE_NOAPI(ret_value); @@ -1379,7 +1355,7 @@ H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Clear to zeros */ - HDmemset(ret_value,0,head->size*elem); + HDmemset(ret_value,0,head->list_arr[elem].size); done: FUNC_LEAVE_NOAPI(ret_value); @@ -1404,8 +1380,6 @@ done: void * H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) { - size_t blk_size; /* Size of block */ - H5FL_arr_node_t *temp; /* Temp. ptr to the new free list node allocated */ void *ret_value; /* Pointer to object to return */ FUNC_ENTER_NOAPI(H5FL_arr_realloc, NULL); @@ -1415,36 +1389,33 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem) assert(new_elem); /* Check if we are really allocating the object */ - if(obj==NULL) { + if(obj==NULL) ret_value=H5FL_arr_malloc(head,new_elem); - } /* end if */ else { - /* Check if there is a maximum number of elements in array */ - if(head->maxelem>0) { - /* Sanity check that the number of elements is supported */ - assert((int)new_elem<=head->maxelem); + H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ - /* Get the pointer to the info header in front of the block to free */ - temp=(H5FL_arr_node_t *)((unsigned char *)obj-sizeof(H5FL_arr_node_t)); + /* Sanity check that the number of elements is supported */ + assert((int)new_elem<=head->maxelem); - /* Check if the size is really changing */ - if(temp->nelem!=new_elem) { - /* Get the new array of objects */ - ret_value=H5FL_arr_malloc(head,new_elem); + /* Get the pointer to the info header in front of the block to free */ + temp=(H5FL_arr_list_t *)((unsigned char *)obj-sizeof(H5FL_arr_list_t)); /*lint !e826 Pointer-to-pointer cast is appropriate here */ - /* Copy the appropriate amount of elements */ - blk_size=head->size*MIN(temp->nelem,new_elem); - HDmemcpy(ret_value,obj,blk_size); + /* Check if the size is really changing */ + if(temp->nelem!=new_elem) { + size_t blk_size; /* Size of block */ - /* Free the old block */ - H5FL_arr_free(head,obj); - } /* end if */ - else - ret_value=obj; + /* Get the new array of objects */ + ret_value=H5FL_arr_malloc(head,new_elem); + + /* Copy the appropriate amount of elements */ + blk_size=head->size*MIN(temp->nelem,new_elem); + HDmemcpy(ret_value,obj,blk_size); + + /* Free the old block */ + H5FL_arr_free(head,obj); } /* end if */ - /* No fixed number of elements, use block routine */ else - ret_value=H5FL_blk_realloc(&(head->u.queue),obj,head->size*new_elem); + ret_value=obj; } /* end else */ done: @@ -1470,53 +1441,45 @@ done: static herr_t H5FL_arr_gc_list(H5FL_arr_head_t *head) { - H5FL_arr_node_t *arr_free_list; /* Pointer to nodes in free list being garbage collected */ + H5FL_arr_list_t *arr_free_list; /* Pointer to nodes in free list being garbage collected */ void *tmp; /* Temporary node pointer */ - int i; /* Counter for array of free lists */ + 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); - /* Check if the array has a fixed maximum number of elements */ - if(head->maxelem>0) { - /* Walk through the array of free lists */ - for(i=0; i<head->maxelem; i++) { - if(head->onlist[i]>0) { - /* Calculate the total memory used on this list */ - total_mem=head->onlist[i]*i*head->size; + /* Walk through the array of free lists */ + for(u=0; u<(unsigned)head->maxelem; u++) { + if(head->list_arr[u].onlist>0) { + /* Calculate the total memory used on this list */ + total_mem=head->list_arr[u].onlist*head->list_arr[u].size; - /* For each free list being garbage collected, walk through the nodes and free them */ - arr_free_list=head->u.list_arr[i]; - while(arr_free_list!=NULL) { - tmp=arr_free_list->next; + /* For each free list being garbage collected, walk through the nodes and free them */ + arr_free_list=head->list_arr[u].list; + while(arr_free_list!=NULL) { + tmp=arr_free_list->next; - /* Decrement the count of nodes allocated and free the node */ - head->allocated--; - H5MM_xfree(arr_free_list); + /* Decrement the count of nodes allocated and free the node */ + head->allocated--; + H5MM_xfree(arr_free_list); - arr_free_list=tmp; - } /* end while */ + arr_free_list=tmp; + } /* end while */ - /* Indicate no free nodes on the free list */ - head->u.list_arr[i]=NULL; - head->onlist[i]=0; + /* Indicate no free nodes on the free list */ + head->list_arr[u].list=NULL; + head->list_arr[u].onlist=0; - /* Decrement count of free memory on this "array" list */ - head->list_mem-=total_mem; + /* Decrement count of free memory on this "array" list */ + head->list_mem-=total_mem; - /* Decrement global count of free memory on "array" lists */ - H5FL_arr_gc_head.mem_freed-=total_mem; - } /* end if */ - - } /* end for */ - - /* Double check that all the memory on this list is recycled */ - assert(head->list_mem==0); + /* Decrement global count of free memory on "array" lists */ + H5FL_arr_gc_head.mem_freed-=total_mem; + } /* end if */ + } /* end for */ - } /* end if */ - /* No maximum number of elements, use the block call to garbage collect */ - else - H5FL_blk_gc_list(&(head->u.queue)); + /* Double check that all the memory on this list is recycled */ + assert(head->list_mem==0); FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5FL_arr_gc_list() */ @@ -1593,51 +1556,25 @@ H5FL_arr_term(void) while(H5FL_arr_gc_head.first!=NULL) { tmp=H5FL_arr_gc_head.first->next; - /* Check if the array has a fixed maximum number of elements */ - if(H5FL_arr_gc_head.first->list->maxelem>0) { - /* Check if the list has allocations outstanding */ + /* Check if the list has allocations outstanding */ #ifdef H5FL_DEBUG printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.first->list->name,(int)H5FL_arr_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ - if(H5FL_arr_gc_head.first->list->allocated>0) { - /* Add free list to the list of nodes with allocations open still */ - H5FL_arr_gc_head.first->next=left; - left=H5FL_arr_gc_head.first; - } /* end if */ - /* No allocations left open for list, get rid of it */ - else { - /* Free the array of free lists */ - H5MM_xfree(H5FL_arr_gc_head.first->list->u.list_arr); - - /* Free the array of "onlist" counts */ - H5MM_xfree(H5FL_arr_gc_head.first->list->onlist); - - /* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */ - H5FL_arr_gc_head.first->list->init=0; - - /* Free the node from the garbage collection list */ - H5MM_xfree(H5FL_arr_gc_head.first); - } /* end else */ + if(H5FL_arr_gc_head.first->list->allocated>0) { + /* Add free list to the list of nodes with allocations open still */ + H5FL_arr_gc_head.first->next=left; + left=H5FL_arr_gc_head.first; } /* end if */ - /* No maximum number of elements, use the PQ information */ + /* No allocations left open for list, get rid of it */ else { -#ifdef H5FL_DEBUG -printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.first->list->name,(int)H5FL_arr_gc_head.first->list->u.queue.allocated); -#endif /* H5FL_DEBUG */ - /* Check if the list has allocations outstanding */ - if(H5FL_arr_gc_head.first->list->u.queue.allocated>0) { - /* Add free list to the list of nodes with allocations open still */ - H5FL_arr_gc_head.first->next=left; - left=H5FL_arr_gc_head.first; - } /* end if */ - /* No allocations left open for list, get rid of it */ - else { - /* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */ - H5FL_arr_gc_head.first->list->init=0; + /* Free the array of free lists */ + H5MM_xfree(H5FL_arr_gc_head.first->list->list_arr); - /* Free the node from the garbage collection list */ - H5MM_xfree(H5FL_arr_gc_head.first); - } /* end else */ + /* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */ + H5FL_arr_gc_head.first->list->init=0; + + /* Free the node from the garbage collection list */ + H5MM_xfree(H5FL_arr_gc_head.first); } /* end else */ H5FL_arr_gc_head.first=tmp; @@ -1651,6 +1588,148 @@ printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.fi /*------------------------------------------------------------------------- + * Function: H5FL_seq_free + * + * Purpose: Release a sequence of objects & put on free list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Saturday, April 3, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +void * +H5FL_seq_free(H5FL_seq_head_t *head, void *obj) +{ + void *ret_value=NULL; /* Return value */ + + FUNC_ENTER_NOAPI(H5FL_seq_free, NULL) + + /* The H5MM_xfree code allows obj to null */ + if (!obj) + HGOTO_DONE (NULL) + + /* Double check parameters */ + assert(head); + + /* Make certain that the free list is initialized */ + assert(head->queue.init); + + /* Use block routine */ + H5FL_blk_free(&(head->queue),obj); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FL_seq_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5FL_seq_malloc + * + * Purpose: Allocate a sequence of objects + * + * Return: Success: Pointer to a valid sequence object + * Failure: NULL + * + * Programmer: Quincey Koziol + * Saturday, April 3, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +void * +H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem) +{ + void *ret_value; /* Pointer to object to return */ + + FUNC_ENTER_NOAPI(H5FL_seq_malloc, NULL) + + /* Double check parameters */ + assert(head); + assert(elem); + + /* Use block routine */ + ret_value=H5FL_blk_malloc(&(head->queue),head->size*elem); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FL_seq_malloc() */ + + +/*------------------------------------------------------------------------- + * Function: H5FL_seq_calloc + * + * Purpose: Allocate a sequence of objects and clear it to zeros + * + * Return: Success: Pointer to a valid array object + * Failure: NULL + * + * Programmer: Quincey Koziol + * Saturday, April 3, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +void * +H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem) +{ + void *ret_value; /* Pointer to object to return */ + + FUNC_ENTER_NOAPI(H5FL_seq_calloc, NULL) + + /* Double check parameters */ + assert(head); + assert(elem); + + /* Use block routine */ + ret_value=H5FL_blk_calloc(&(head->queue),head->size*elem); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FL_seq_calloc() */ + + +/*------------------------------------------------------------------------- + * Function: H5FL_seq_realloc + * + * Purpose: Reallocate a sequence of objects + * + * Return: Success: Pointer to a valid sequence object + * Failure: NULL + * + * Programmer: Quincey Koziol + * Saturday, April 3, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +void * +H5FL_seq_realloc(H5FL_seq_head_t *head, void * obj, size_t new_elem) +{ + void *ret_value; /* Pointer to object to return */ + + FUNC_ENTER_NOAPI(H5FL_seq_realloc, NULL) + + /* Double check parameters */ + assert(head); + assert(new_elem); + + /* Use block routine */ + ret_value=H5FL_blk_realloc(&(head->queue),obj,head->size*new_elem); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FL_seq_realloc() */ + + +/*------------------------------------------------------------------------- * Function: H5FL_garbage_coll * * Purpose: Garbage collect on all the free lists diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h index 4f3d938..c1fbfae 100644 --- a/src/H5FLprivate.h +++ b/src/H5FLprivate.h @@ -39,6 +39,7 @@ #ifdef H5_NO_FREE_LISTS #define H5_NO_REG_FREE_LISTS #define H5_NO_ARR_FREE_LISTS +#define H5_NO_SEQ_FREE_LISTS #define H5_NO_BLK_FREE_LISTS #endif /* H5_NO_FREE_LISTS */ @@ -137,7 +138,7 @@ typedef struct H5FL_blk_head_t { #define H5FL_BLK_NAME(t) H5_##t##_blk_free_list #ifndef H5_NO_BLK_FREE_LISTS /* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ -#define H5FL_BLK_DEFINE_COMMON(t) H5FL_blk_head_t H5FL_BLK_NAME(t)={0,0,0,0,#t,NULL} +#define H5FL_BLK_DEFINE_COMMON(t) H5FL_blk_head_t H5FL_BLK_NAME(t)={0,0,0,0,#t"_blk",NULL} /* Declare a free list to manage objects of type 't' */ #define H5FL_BLK_DEFINE(t) H5_DLL H5FL_BLK_DEFINE_COMMON(t) @@ -178,26 +179,29 @@ typedef struct H5FL_blk_head_t { #endif /* H5_NO_BLK_FREE_LISTS */ /* Data structure to store each array in free list */ -typedef union H5FL_arr_node_t { - union H5FL_arr_node_t *next; /* Pointer to next block in free list */ +typedef union H5FL_arr_list_t { + union H5FL_arr_list_t *next; /* Pointer to next block in free list */ size_t nelem; /* Number of elements in this array */ double unused1; /* Unused normally, just here for aligment */ haddr_t unused2; /* Unused normally, just here for aligment */ +} H5FL_arr_list_t; + +/* Data structure for each size of array element */ +typedef struct H5FL_arr_node_t { + size_t size; /* Size of the blocks in the list */ + unsigned onlist; /* Number of blocks on free list */ + H5FL_arr_list_t *list; /* List of free blocks */ } H5FL_arr_node_t; /* Data structure for free list of array blocks */ typedef struct H5FL_arr_head_t { unsigned init; /* Whether the free list has been initialized */ unsigned allocated; /* Number of blocks allocated */ - unsigned *onlist; /* Number of blocks on free list */ - size_t list_mem; /* Amount of memory in block on free list */ - const char *name; /* Name of the type */ - int maxelem; /* Maximum number of elements in an array */ - size_t size; /* Size of the array elements in the list */ - union { - H5FL_arr_node_t **list_arr; /* Array of lists of free blocks */ - H5FL_blk_head_t queue; /* Priority queue of array blocks */ - }u; + size_t list_mem; /* Amount of memory in block on free list */ + const char *name; /* Name of the type */ + int maxelem; /* Maximum number of elements in an array */ + size_t size; /* Size of the array elements in the list */ + H5FL_arr_node_t *list_arr; /* Array of lists of free blocks */ } H5FL_arr_head_t; /* @@ -206,7 +210,7 @@ typedef struct H5FL_arr_head_t { #define H5FL_ARR_NAME(t) H5_##t##_arr_free_list #ifndef H5_NO_ARR_FREE_LISTS /* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ -#define H5FL_ARR_DEFINE_COMMON(t,m) H5FL_arr_head_t H5FL_ARR_NAME(t)={0,0,NULL,0,#t"_arr",m+1,sizeof(t),{NULL}} +#define H5FL_ARR_DEFINE_COMMON(t,m) H5FL_arr_head_t H5FL_ARR_NAME(t)={0,0,0,#t"_arr",m+1,sizeof(t),NULL} /* Declare a free list to manage arrays of type 't' */ #define H5FL_ARR_DEFINE(t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(t,m) @@ -230,7 +234,7 @@ typedef struct H5FL_arr_head_t { #define H5FL_ARR_REALLOC(t,obj,new_elem) H5FL_arr_realloc(&(H5FL_ARR_NAME(t)),obj,new_elem) #else /* H5_NO_ARR_FREE_LISTS */ -/* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ +/* Common macro for H5FL_ARR_DEFINE & H5FL_ARR_DEFINE_STATIC */ #define H5FL_ARR_DEFINE_COMMON(t,m) int H5FL_ARR_NAME(t) #define H5FL_ARR_DEFINE(t,m) H5_DLL H5FL_ARR_DEFINE_COMMON(t,m) @@ -242,6 +246,57 @@ typedef struct H5FL_arr_head_t { #define H5FL_ARR_REALLOC(t,obj,new_elem) H5MM_realloc(obj,(new_elem)*sizeof(t)) #endif /* H5_NO_ARR_FREE_LISTS */ +/* Data structure for free list of sequence blocks */ +typedef struct H5FL_seq_head_t { + H5FL_blk_head_t queue; /* Priority queue of sequence blocks */ + size_t size; /* Size of the sequence elements in the list */ +} H5FL_seq_head_t; + +/* + * Macros for defining & using free lists for a sequence of a type + * + * Sequences are like arrays, except they have no upper limit. + * + */ +#define H5FL_SEQ_NAME(t) H5_##t##_seq_free_list +#ifndef H5_NO_SEQ_FREE_LISTS +/* Common macro for H5FL_SEQ_DEFINE & H5FL_SEQ_DEFINE_STATIC */ +#define H5FL_SEQ_DEFINE_COMMON(t) H5FL_seq_head_t H5FL_SEQ_NAME(t)={{0,0,0,0,#t"_seq",NULL},sizeof(t)} + +/* Declare a free list to manage sequences of type 't' */ +#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) + +/* Reference a free list for sequences of type 't' defined in another file */ +#define H5FL_SEQ_EXTERN(t) extern H5_DLL H5FL_seq_head_t H5FL_SEQ_NAME(t) + +/* Declare a static free list to manage sequences of type 't' */ +#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) + +/* Allocate a sequence of type 't' */ +#define H5FL_SEQ_MALLOC(t,elem) H5FL_seq_malloc(&(H5FL_SEQ_NAME(t)),elem) + +/* Allocate a sequence of type 't' and clear it to all zeros */ +#define H5FL_SEQ_CALLOC(t,elem) H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)),elem) + +/* Free a sequence of type 't' */ +#define H5FL_SEQ_FREE(t,obj) H5FL_seq_free(&(H5FL_SEQ_NAME(t)),obj) + +/* Re-allocate a sequence of type 't' */ +#define H5FL_SEQ_REALLOC(t,obj,new_elem) H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)),obj,new_elem) + +#else /* H5_NO_SEQ_FREE_LISTS */ +/* Common macro for H5FL_BLK_DEFINE & H5FL_BLK_DEFINE_STATIC */ +#define H5FL_SEQ_DEFINE_COMMON(t) int H5FL_SEQ_NAME(t) + +#define H5FL_SEQ_DEFINE(t) H5_DLL H5FL_SEQ_DEFINE_COMMON(t) +#define H5FL_SEQ_EXTERN(t) extern H5_DLL int H5FL_SEQ_NAME(t) +#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t) +#define H5FL_SEQ_MALLOC(t,elem) H5MM_malloc((elem)*sizeof(t)) +#define H5FL_SEQ_CALLOC(t,elem) H5MM_calloc((elem)*sizeof(t)) +#define H5FL_SEQ_FREE(t,obj) H5MM_xfree(obj) +#define H5FL_SEQ_REALLOC(t,obj,new_elem) H5MM_realloc(obj,(new_elem)*sizeof(t)) +#endif /* H5_NO_SEQ_FREE_LISTS */ + /* * Library prototypes. */ @@ -257,6 +312,10 @@ H5_DLL void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem); H5_DLL void * H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem); H5_DLL void * H5FL_arr_free(H5FL_arr_head_t *head, void *obj); H5_DLL void * H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem); +H5_DLL void * H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem); +H5_DLL void * H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem); +H5_DLL void * H5FL_seq_free(H5FL_seq_head_t *head, void *obj); +H5_DLL void * H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem); H5_DLL herr_t H5FL_garbage_coll(void); H5_DLL herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim); diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 379d06f..672cd31 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -134,7 +134,7 @@ static int interface_initialize_g = 0; H5FL_DEFINE_STATIC(H5G_node_t); /* Declare a free list to manage arrays of H5G_entry_t's */ -H5FL_ARR_DEFINE_STATIC(H5G_entry_t,-1); +H5FL_SEQ_DEFINE_STATIC(H5G_entry_t); /* Declare a free list to manage blocks of symbol node data */ H5FL_BLK_DEFINE_STATIC(symbol_node); @@ -352,7 +352,7 @@ H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_udata1 HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for symbol table node"); p=buf; if (NULL==(sym = H5FL_CALLOC(H5G_node_t)) || - NULL==(sym->entry=H5FL_ARR_CALLOC(H5G_entry_t,(2*H5F_SYM_LEAF_K(f))))) + NULL==(sym->entry=H5FL_SEQ_CALLOC(H5G_entry_t,(2*H5F_SYM_LEAF_K(f))))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); if (H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, buf) < 0) HGOTO_ERROR(H5E_SYM, H5E_READERROR, NULL, "unable to read symbol table node"); @@ -527,7 +527,7 @@ H5G_node_dest(H5F_t UNUSED *f, H5G_node_t *sym) assert (sym->cache_info.dirty==0); if(sym->entry) - sym->entry = H5FL_ARR_FREE(H5G_entry_t,sym->entry); + sym->entry = H5FL_SEQ_FREE(H5G_entry_t,sym->entry); H5FL_FREE(H5G_node_t,sym); FUNC_LEAVE_NOAPI(SUCCEED); @@ -616,7 +616,7 @@ H5G_node_create(H5F_t *f, hid_t dxpl_id, H5B_ins_t UNUSED op, void *_lt_key, if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, size))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to allocate file space"); sym->cache_info.dirty = TRUE; - sym->entry = H5FL_ARR_CALLOC(H5G_entry_t,(2*H5F_SYM_LEAF_K(f))); + sym->entry = H5FL_SEQ_CALLOC(H5G_entry_t,(2*H5F_SYM_LEAF_K(f))); if (NULL==sym->entry) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); if (H5AC_set(f, dxpl_id, H5AC_SNODE, *addr_p, sym) < 0) @@ -636,7 +636,7 @@ done: if(ret_value<0) { if(sym!=NULL) { if(sym->entry!=NULL) - H5FL_ARR_FREE(H5G_entry_t,sym->entry); + H5FL_SEQ_FREE(H5G_entry_t,sym->entry); H5FL_FREE(H5G_node_t,sym); } /* end if */ } /* end if */ @@ -175,7 +175,7 @@ static int interface_initialize_g = 0; H5FL_DEFINE_STATIC(H5HG_heap_t); /* Declare a free list to manage arrays of H5HG_obj_t's */ -H5FL_ARR_DEFINE_STATIC(H5HG_obj_t,-1); +H5FL_SEQ_DEFINE_STATIC(H5HG_obj_t); /* Declare a PQ free list to manage heap chunks */ H5FL_BLK_DEFINE_STATIC(heap_chunk); @@ -231,7 +231,7 @@ H5HG_create (H5F_t *f, hid_t dxpl_id, size_t size) if (NULL==(heap->chunk = H5FL_BLK_MALLOC (heap_chunk,size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); heap->nalloc = H5HG_NOBJS (f, size); - if (NULL==(heap->obj = H5FL_ARR_CALLOC (H5HG_obj_t,heap->nalloc))) + if (NULL==(heap->obj = H5FL_SEQ_CALLOC (H5HG_obj_t,heap->nalloc))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Initialize the header */ @@ -369,7 +369,7 @@ H5HG_load (H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, /* Decode each object */ p = heap->chunk + H5HG_SIZEOF_HDR (f); nalloc = H5HG_NOBJS (f, heap->size); - if (NULL==(heap->obj = H5FL_ARR_CALLOC (H5HG_obj_t,nalloc))) + if (NULL==(heap->obj = H5FL_SEQ_CALLOC (H5HG_obj_t,nalloc))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); heap->nalloc = nalloc; while (p<heap->chunk+heap->size) { @@ -532,7 +532,7 @@ H5HG_dest (H5F_t *f, H5HG_heap_t *heap) } } heap->chunk = H5FL_BLK_FREE(heap_chunk,heap->chunk); - heap->obj = H5FL_ARR_FREE(H5HG_obj_t,heap->obj); + heap->obj = H5FL_SEQ_FREE(H5HG_obj_t,heap->obj); H5FL_FREE (H5HG_heap_t,heap); FUNC_LEAVE_NOAPI(SUCCEED); @@ -62,7 +62,7 @@ static herr_t H5HP_sink_min(H5HP_t *heap, size_t loc); H5FL_DEFINE_STATIC(H5HP_t); /* Declare a free list to manage arrays of H5HP_ent_t */ -H5FL_ARR_DEFINE_STATIC(H5HP_ent_t,-1); +H5FL_SEQ_DEFINE_STATIC(H5HP_ent_t); /*-------------------------------------------------------------------------- @@ -354,7 +354,7 @@ H5HP_create(H5HP_type_t heap_type) HGOTO_ERROR(H5E_HEAP,H5E_NOSPACE,NULL,"memory allocation failed"); /* Allocate the array to store the heap entries */ - if((new_heap->heap=H5FL_ARR_MALLOC(H5HP_ent_t, H5HP_START_SIZE+1))==NULL) + if((new_heap->heap=H5FL_SEQ_MALLOC(H5HP_ent_t, H5HP_START_SIZE+1))==NULL) HGOTO_ERROR(H5E_HEAP,H5E_NOSPACE,NULL,"memory allocation failed"); /* Set the internal fields */ @@ -386,7 +386,7 @@ done: if(ret_value==NULL) { if(new_heap!=NULL) { if(new_heap->heap!=NULL) - H5FL_ARR_FREE(H5HP_ent_t,new_heap->heap); + H5FL_SEQ_FREE(H5HP_ent_t,new_heap->heap); H5FL_FREE(H5HP_t,new_heap); } /* end if */ } /* end if */ @@ -487,7 +487,7 @@ H5HP_insert(H5HP_t *heap, int val, void *obj) /* Check if we need to allocate more room for heap array */ if(heap->nobjs>=heap->nalloc) { size_t n = MAX(H5HP_START_SIZE, 2*(heap->nalloc-1)) + 1; - H5HP_ent_t *new_heap = H5FL_ARR_REALLOC(H5HP_ent_t,heap->heap, n); + H5HP_ent_t *new_heap = H5FL_SEQ_REALLOC(H5HP_ent_t,heap->heap, n); if (!new_heap) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend heap array"); @@ -924,7 +924,7 @@ H5HP_close(H5HP_t *heap) assert(heap->heap[0].obj==NULL); /* Free internal structures for heap */ - H5FL_ARR_FREE(H5HP_ent_t,heap->heap); + H5FL_SEQ_FREE(H5HP_ent_t,heap->heap); /* Free actual heap object */ H5FL_FREE(H5HP_t,heap); @@ -141,10 +141,10 @@ static void *(*H5O_fast_g[H5G_NCACHED]) (const H5G_cache_t *, H5FL_DEFINE_STATIC(H5O_t); /* Declare a PQ free list to manage the H5O_mesg_t array information */ -H5FL_ARR_DEFINE_STATIC(H5O_mesg_t,-1); +H5FL_SEQ_DEFINE_STATIC(H5O_mesg_t); /* Declare a PQ free list to manage the H5O_chunk_t array information */ -H5FL_ARR_DEFINE_STATIC(H5O_chunk_t,-1); +H5FL_SEQ_DEFINE_STATIC(H5O_chunk_t); /* Declare a PQ free list to manage the chunk image information */ H5FL_BLK_DEFINE_STATIC(chunk_image); @@ -287,7 +287,7 @@ H5O_init(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/, had oh->nchunks = 1; oh->alloc_nchunks = H5O_NCHUNKS; - if (NULL == (oh->chunk = H5FL_ARR_MALLOC(H5O_chunk_t, oh->alloc_nchunks))) + if (NULL == (oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, oh->alloc_nchunks))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); tmp_addr = ent->header + (hsize_t)H5O_SIZEOF_HDR(f); @@ -302,7 +302,7 @@ H5O_init(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/, had oh->nmesgs = 1; oh->alloc_nmesgs = H5O_NMESGS; - if (NULL == (oh->mesg = H5FL_ARR_CALLOC(H5O_mesg_t, oh->alloc_nmesgs))) + if (NULL == (oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); oh->mesg[0].type = H5O_NULL; @@ -516,7 +516,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1, /* build the message array */ oh->alloc_nmesgs = MAX(H5O_NMESGS, nmesgs); - if (NULL==(oh->mesg=H5FL_ARR_CALLOC(H5O_mesg_t,oh->alloc_nmesgs))) + if (NULL==(oh->mesg=H5FL_SEQ_CALLOC(H5O_mesg_t,oh->alloc_nmesgs))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* read each chunk from disk */ @@ -525,7 +525,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1, /* increase chunk array size */ if (oh->nchunks >= oh->alloc_nchunks) { unsigned na = oh->alloc_nchunks + H5O_NCHUNKS; - H5O_chunk_t *x = H5FL_ARR_REALLOC (H5O_chunk_t, oh->chunk, na); + H5O_chunk_t *x = H5FL_SEQ_REALLOC (H5O_chunk_t, oh->chunk, na); if (!x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); @@ -830,7 +830,7 @@ H5O_dest(H5F_t UNUSED *f, H5O_t *oh) oh->chunk[i].image = H5FL_BLK_FREE(chunk_image,oh->chunk[i].image); } - oh->chunk = H5FL_ARR_FREE(H5O_chunk_t,oh->chunk); + oh->chunk = H5FL_SEQ_FREE(H5O_chunk_t,oh->chunk); /* destroy messages */ for (i = 0; i < oh->nmesgs; i++) { @@ -842,7 +842,7 @@ H5O_dest(H5F_t UNUSED *f, H5O_t *oh) else H5O_free_real(oh->mesg[i].type, oh->mesg[i].native); } - oh->mesg = H5FL_ARR_FREE(H5O_mesg_t,oh->mesg); + oh->mesg = H5FL_SEQ_FREE(H5O_mesg_t,oh->mesg); /* destroy object header */ H5FL_FREE(H5O_t,oh); @@ -2589,7 +2589,7 @@ H5O_alloc_extend_chunk(H5O_t *oh, unsigned chunkno, size_t size) /* create a new null message */ if (oh->nmesgs >= oh->alloc_nmesgs) { unsigned na = oh->alloc_nmesgs + H5O_NMESGS; - H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na); + H5O_mesg_t *x = H5FL_SEQ_REALLOC (H5O_mesg_t, oh->mesg, na); if (NULL==x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed"); @@ -2731,7 +2731,7 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size) */ if (oh->nchunks >= oh->alloc_nchunks) { unsigned na = oh->alloc_nchunks + H5O_NCHUNKS; - H5O_chunk_t *x = H5FL_ARR_REALLOC (H5O_chunk_t, oh->chunk, na); + H5O_chunk_t *x = H5FL_SEQ_REALLOC (H5O_chunk_t, oh->chunk, na); if (!x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed"); @@ -2752,7 +2752,7 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size) if (oh->nmesgs + 3 > oh->alloc_nmesgs) { int old_alloc=oh->alloc_nmesgs; unsigned na = oh->alloc_nmesgs + MAX (H5O_NMESGS, 3); - H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na); + H5O_mesg_t *x = H5FL_SEQ_REALLOC (H5O_mesg_t, oh->mesg, na); if (!x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed"); @@ -2918,7 +2918,7 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size) if (oh->nmesgs >= oh->alloc_nmesgs) { int old_alloc=oh->alloc_nmesgs; unsigned na = oh->alloc_nmesgs + H5O_NMESGS; - H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na); + H5O_mesg_t *x = H5FL_SEQ_REALLOC (H5O_mesg_t, oh->mesg, na); if (!x) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed"); @@ -60,7 +60,7 @@ H5FL_DEFINE(H5S_simple_t); H5FL_DEFINE(H5S_t); /* Declare a free list to manage the array's of hsize_t's */ -H5FL_ARR_DEFINE(hsize_t,-1); +H5FL_ARR_DEFINE(hsize_t,H5S_MAX_RANK); /* Declare a free list to manage the array's of hssize_t's */ H5FL_ARR_DEFINE(hssize_t,H5S_MAX_RANK); diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 6eac242..c35f13e 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -44,12 +44,15 @@ static herr_t H5S_select_iter_next_block(H5S_sel_iter_t *iter); /* Declare external the free list for hssize_t arrays */ H5FL_ARR_EXTERN(hssize_t); -/* Declare a free list to manage arrays of size_t */ -H5FL_ARR_DEFINE_STATIC(size_t,-1); - -/* Declare a free list to manage arrays of hsize_t */ +/* Declare external the free list for hsize_t arrays */ H5FL_ARR_EXTERN(hsize_t); +/* Declare a free list to manage sequences of size_t */ +H5FL_SEQ_DEFINE_STATIC(size_t); + +/* Declare a free list to manage sequences of hsize_t */ +H5FL_SEQ_DEFINE_STATIC(hsize_t); + /* Declare a free list to manage blocks of single datatype element data */ H5FL_BLK_EXTERN(type_elem); @@ -985,9 +988,9 @@ H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get I/O vector size"); /* Allocate the vector I/O arrays */ - if((len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL) + if((len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); - if((off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL) + if((off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); /* Get the datatype size */ @@ -1071,9 +1074,9 @@ done: /* Release length & offset vectors */ if(len!=NULL) - H5FL_ARR_FREE(size_t,len); + H5FL_SEQ_FREE(size_t,len); if(off!=NULL) - H5FL_ARR_FREE(hsize_t,off); + H5FL_SEQ_FREE(hsize_t,off); FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_select_iterate() */ @@ -1428,9 +1431,9 @@ H5S_select_fill(void *_fill, size_t fill_size, const H5S_t *space, void *_buf) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get I/O vector size"); /* Allocate the vector I/O arrays */ - if((len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL) + if((len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); - if((off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL) + if((off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); /* Initialize iterator */ @@ -1475,9 +1478,9 @@ done: /* Release length & offset vectors */ if(len!=NULL) - H5FL_ARR_FREE(size_t,len); + H5FL_SEQ_FREE(size_t,len); if(off!=NULL) - H5FL_ARR_FREE(hsize_t,off); + H5FL_SEQ_FREE(hsize_t,off); /* Release fill value, if allocated */ if(_fill==NULL && fill) @@ -1542,9 +1545,9 @@ H5S_select_fscat (H5F_t *f, struct H5O_layout_t *layout, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get I/O vector size"); /* Allocate the vector I/O arrays */ - if((len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL) + if((len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); - if((off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL) + if((off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); /* Compute the number of bytes available in buffer */ @@ -1575,9 +1578,9 @@ H5S_select_fscat (H5F_t *f, struct H5O_layout_t *layout, done: if(len!=NULL) - H5FL_ARR_FREE(size_t,len); + H5FL_SEQ_FREE(size_t,len); if(off!=NULL) - H5FL_ARR_FREE(hsize_t,off); + H5FL_SEQ_FREE(hsize_t,off); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_fscat() */ @@ -1641,9 +1644,9 @@ H5S_select_fgath (H5F_t *f, const struct H5O_layout_t *layout, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "unable to get I/O vector size"); /* Allocate the vector I/O arrays */ - if((len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL) + if((len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O length vector array"); - if((off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL) + if((off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O offset vector array"); /* Compute the number of bytes available in buffer */ @@ -1674,9 +1677,9 @@ H5S_select_fgath (H5F_t *f, const struct H5O_layout_t *layout, done: if(len!=NULL) - H5FL_ARR_FREE(size_t,len); + H5FL_SEQ_FREE(size_t,len); if(off!=NULL) - H5FL_ARR_FREE(hsize_t,off); + H5FL_SEQ_FREE(hsize_t,off); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_fgath() */ @@ -1729,9 +1732,9 @@ H5S_select_mscat (const void *_tscat_buf, size_t elmt_size, const H5S_t *space, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get I/O vector size"); /* Allocate the vector I/O arrays */ - if((len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL) + if((len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); - if((off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL) + if((off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); /* Compute the number of bytes available in buffer */ @@ -1761,9 +1764,9 @@ H5S_select_mscat (const void *_tscat_buf, size_t elmt_size, const H5S_t *space, done: if(len!=NULL) - H5FL_ARR_FREE(size_t,len); + H5FL_SEQ_FREE(size_t,len); if(off!=NULL) - H5FL_ARR_FREE(hsize_t,off); + H5FL_SEQ_FREE(hsize_t,off); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_mscat() */ @@ -1818,9 +1821,9 @@ H5S_select_mgath (const void *_buf, size_t elmt_size, const H5S_t *space, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "unable to get I/O vector size"); /* Allocate the vector I/O arrays */ - if((len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL) + if((len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O length vector array"); - if((off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL) + if((off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O offset vector array"); /* Compute the number of bytes available in buffer */ @@ -1850,9 +1853,9 @@ H5S_select_mgath (const void *_buf, size_t elmt_size, const H5S_t *space, done: if(len!=NULL) - H5FL_ARR_FREE(size_t,len); + H5FL_SEQ_FREE(size_t,len); if(off!=NULL) - H5FL_ARR_FREE(hsize_t,off); + H5FL_SEQ_FREE(hsize_t,off); FUNC_LEAVE_NOAPI(ret_value); } /* H5S_select_mgath() */ @@ -1918,13 +1921,13 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get I/O vector size"); /* Allocate the vector I/O arrays */ - if((mem_len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL) + if((mem_len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); - if((mem_off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL) + if((mem_off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); - if((file_len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL) + if((file_len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); - if((file_off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL) + if((file_off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); /* Get number of bytes in selection */ @@ -1995,13 +1998,13 @@ done: /* Free vector arrays */ if(file_len!=NULL) - H5FL_ARR_FREE(size_t,file_len); + H5FL_SEQ_FREE(size_t,file_len); if(file_off!=NULL) - H5FL_ARR_FREE(hsize_t,file_off); + H5FL_SEQ_FREE(hsize_t,file_off); if(mem_len!=NULL) - H5FL_ARR_FREE(size_t,mem_len); + H5FL_SEQ_FREE(size_t,mem_len); if(mem_off!=NULL) - H5FL_ARR_FREE(hsize_t,mem_off); + H5FL_SEQ_FREE(hsize_t,mem_off); FUNC_LEAVE_NOAPI(ret_value); } /* end H5S_select_read() */ @@ -2066,13 +2069,13 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, H5P_genplist_t *dc_plist, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get I/O vector size"); /* Allocate the vector I/O arrays */ - if((mem_len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL) + if((mem_len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); - if((mem_off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL) + if((mem_off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); - if((file_len = H5FL_ARR_MALLOC(size_t,(size_t)vector_size))==NULL) + if((file_len = H5FL_SEQ_MALLOC(size_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array"); - if((file_off = H5FL_ARR_MALLOC(hsize_t,(size_t)vector_size))==NULL) + if((file_off = H5FL_SEQ_MALLOC(hsize_t,(size_t)vector_size))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); /* Initialize file iterator */ @@ -2186,13 +2189,13 @@ done: /* Free vector arrays */ if(file_len!=NULL) - H5FL_ARR_FREE(size_t,file_len); + H5FL_SEQ_FREE(size_t,file_len); if(file_off!=NULL) - H5FL_ARR_FREE(hsize_t,file_off); + H5FL_SEQ_FREE(hsize_t,file_off); if(mem_len!=NULL) - H5FL_ARR_FREE(size_t,mem_len); + H5FL_SEQ_FREE(size_t,mem_len); if(mem_off!=NULL) - H5FL_ARR_FREE(hsize_t,mem_off); + H5FL_SEQ_FREE(hsize_t,mem_off); #ifdef QAK { int mpi_rank; |