Item

ItemPutCL

Copy a known number of bytes into an ITEM

Syntax

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

Arguments

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

value points to a readable buffer.

length gives the number of bytes to copy, excluding the terminator.

Return value

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

Description

The function appends a NUL terminator and stores the length separately. Embedded zero bytes are retained. The source buffer remains owned by the caller.

Example

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

#include <stdio.h>

int main( void )
{
   const char data[] = { 'A', '\0', 'B' };
   ITEM *item = ItemPutCL( NULL, data, sizeof( data ) );

   printf( "%zu bytes\n", ItemGetCLen( item ) );
   ItemRelease( item );

   return 0;
}

Output

3 bytes

See also