Syntax
ITEM *ItemPutBlock( ITEM *item, ItemBlock block );
Arguments
item is an existing ITEM to replace. Pass NULL to allocate a new ITEM.
block is a callback that accepts an int and returns an int.
Return value
The destination ITEM, or a new caller-owned ITEM when item is NULL.
Description
Stores the function pointer as IT_BLOCK. Read the callback with ItemGetBlock().
Example
#include "xdev-wtui.h"
#include <stdio.h>
static int doubleValue( int value )
{
return value * 2;
}
int main( void )
{
ITEM *item = ItemPutBlock( NULL, doubleValue );
ItemBlock operation = ItemGetBlock( item );
if( operation )
printf( "%d\n", operation( 21 ) );
ItemRelease( item );
return 0;
}
Output
42