void bli_pool_checkout_block( pblk_t* block, pool_t* pool ) { pblk_t* block_ptrs; dim_t top_index; // If the pool is exhausted, add a block. if ( bli_pool_is_exhausted( pool ) ) { bli_pool_grow( 1, pool ); } // At this point, at least one block is guaranteed to be available. // Query the current block_ptrs array. block_ptrs = bli_pool_block_ptrs( pool ); // Query the top_index of the pool. top_index = bli_pool_top_index( pool ); // Copy the block at top_index to the caller's pblk_t struct. //bli_pblk_copy( *(block_ptrs[top_index]), *block ); *block = block_ptrs[top_index]; // Notice that we don't actually need to clear the contents of // block_ptrs[top_index]. It will get overwritten eventually when // the block is checked back in. bli_pblk_clear( &block_ptrs[top_index] ); // Increment the pool's top_index. bli_pool_set_top_index( top_index + 1, pool ); }
err_t bli_check_if_exhausted_pool( pool_t* pool ) { err_t e_val = BLIS_SUCCESS; if ( bli_pool_is_exhausted( pool ) ) e_val = BLIS_EXHAUSTED_CONTIG_MEMORY_POOL; return e_val; }