Item

ArrayAdd

Append a copy of an ITEM to an array

Syntax

Signature
int ArrayAdd( ITEM *array, const ITEM *value );

Arguments

array is the array to extend.

value is the value to append. Pass NULL to add NIL.

Return value

1 if the element was appended, or 0 if the destination is invalid or has another type.

Description

The array grows by one slot and owns the appended copy. Reacquire borrowed element pointers after appending because storage can move.

Example

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

#include <stdio.h>

int main( void )
{
   ITEM *array = Array( 0 );
   ITEM *value = ItemPutC( NULL, "Open" );

   if( !ArrayAdd( array, value ) )
   {
      ItemRelease( value );
      ItemRelease( array );
      return 1;
   }
   ItemRelease( value );
   puts( ArrayGetCPtr( array, 1 ) );
   ItemRelease( array );

   return 0;
}

Output

Open

See also