\r
/* Save the pool parameters. Set grow_size to min for initialization. */\r
h_pool->max = max;\r
- h_pool->grow_size = min;\r
-\r
- /* Grow the pool to the minimum size. */\r
- status = __grow_mad_pool( h_pool, NULL );\r
- if( status != IB_SUCCESS )\r
+ if( min )\r
{\r
- h_pool->obj.pfn_destroy( &h_pool->obj, NULL );\r
- CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl,\r
- ("grow_mad_pool failed with status %s.\n", ib_get_err_str(status)) );\r
- return status;\r
+ h_pool->grow_size = min;\r
+\r
+ /* Grow the pool to the minimum size. */\r
+ status = __grow_mad_pool( h_pool, NULL );\r
+ if( status != IB_SUCCESS )\r
+ {\r
+ h_pool->obj.pfn_destroy( &h_pool->obj, NULL );\r
+ CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl,\r
+ ("grow_mad_pool failed with status %s.\n",\r
+ ib_get_err_str(status)) );\r
+ return status;\r
+ }\r
}\r
\r
/* Save the grow_size for subsequent allocations. */\r
{\r
al_pool_key_t* p_pool_key;\r
ib_pool_handle_t h_pool;\r
- cl_list_item_t* p_mad_item;\r
- al_mad_element_t* p_mad_element;\r
- mad_item_t* p_mad;\r
+ cl_list_item_t* p_item;\r
+ mad_item_t* p_mad_item;\r
ib_api_status_t status;\r
\r
CL_ENTER( AL_DBG_MAD_POOL, g_al_dbg_lvl );\r
\r
/* Obtain a MAD item from the stack. */\r
cl_spinlock_acquire( &h_pool->obj.lock );\r
- p_mad_item = cl_qlist_remove_head( &h_pool->mad_stack );\r
- p_mad_element = PARENT_STRUCT( p_mad_item, al_mad_element_t, list_item );\r
- p_mad = PARENT_STRUCT( p_mad_element, mad_item_t, al_mad_element );\r
- if( p_mad_item == cl_qlist_end( &h_pool->mad_stack ) )\r
+ p_item = cl_qlist_remove_head( &h_pool->mad_stack );\r
+ p_mad_item = PARENT_STRUCT( p_item, mad_item_t, al_mad_element.list_item );\r
+ if( p_item == cl_qlist_end( &h_pool->mad_stack ) )\r
{\r
/* The stack was empty. Grow the pool and obtain a new item. */\r
cl_spinlock_release( &h_pool->obj.lock );\r
- status = __grow_mad_pool( h_pool, &p_mad );\r
+ status = __grow_mad_pool( h_pool, &p_mad_item );\r
if( status != IB_SUCCESS )\r
{\r
CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl,\r
cl_spinlock_release( &h_pool->obj.lock );\r
}\r
\r
- if( p_mad == NULL )\r
- return IB_INSUFFICIENT_RESOURCES;\r
-\r
/* Get the local data segment information for this pool key. */\r
- status = __init_mad_element( p_pool_key, p_mad );\r
+ status = __init_mad_element( p_pool_key, p_mad_item );\r
if( status != IB_SUCCESS )\r
{\r
cl_spinlock_acquire( &h_pool->obj.lock );\r
cl_qlist_insert_head( &h_pool->mad_stack,\r
- &p_mad_element->list_item );\r
+ &p_mad_item->al_mad_element.list_item );\r
cl_spinlock_release( &h_pool->obj.lock );\r
\r
CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl,\r
}\r
\r
/* Hold a reference on the array while a MAD element is removed. */\r
- ref_al_obj( &p_mad->p_mad_array->obj );\r
+ ref_al_obj( &p_mad_item->p_mad_array->obj );\r
\r
- p_mad->al_mad_element.pool_key = (ib_pool_key_t)pool_key;\r
+ p_mad_item->al_mad_element.pool_key = (ib_pool_key_t)pool_key;\r
/* Return the MAD element. */\r
- *pp_mad_element = &p_mad->al_mad_element;\r
+ *pp_mad_element = &p_mad_item->al_mad_element;\r
\r
CL_EXIT( AL_DBG_MAD_POOL, g_al_dbg_lvl );\r
return IB_SUCCESS;\r
\r
/* Determine if the pool is allowed to grow. */\r
if( h_pool->grow_size == 0 )\r
- {\r
- /* Cannot grow the pool. Clear the p_mad_item if one was provided. */\r
- if( pp_mad_item != NULL) *pp_mad_item = NULL;\r
- return IB_SUCCESS;\r
- }\r
+ return IB_INSUFFICIENT_RESOURCES;\r
\r
/* Lock the pool. */\r
cl_spinlock_acquire( &h_pool->obj.lock );\r