Item

ItemPutCLPtr

Transfer ownership of a text buffer to an ITEM

Syntax

Signature
ITEM *ItemPutCLPtr( ITEM *item, char *value, size_t length );

Arguments

item is an existing ITEM to replace. Pass NULL to allocate a new ITEM.

value points to a heap buffer whose byte at offset length is NUL.

length counts the text bytes before the terminator.

Return value

The destination ITEM, or a new caller-owned ITEM when item is NULL.

Description

Stores the supplied buffer directly. Allocate it with a compatible allocator such as malloc(). ItemClear() or ItemRelease() will free it when the ITEM no longer owns it.

Example

itemputclptr.c
#include "xdev-wtui.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main( void )
{
   char *text = malloc( sizeof( "Ready" ) );

   if( !text )
      return 1;

   memcpy( text, "Ready", sizeof( "Ready" ) );
   ITEM *item = ItemPutCLPtr( NULL, text, sizeof( "Ready" ) - 1 );
   puts( ItemGetCPtr( item ) );
   ItemRelease( item );

   return 0;
}

Output

Ready

See also