TutPtrAryGetItemAtIndex


Name

TutPtrAryGetItemAtIndex — get the item stored at the given index in a pointer array

Synopsis

T_BOOL TutPtrAryGetItemAtIndex(ptr_ary, index, element) 
T_PTR_ARY ptr_ary; 
T_INT4 index; 
T_PTR *element; 

Arguments

ptr_ary — pointer array to get the element from

index — index of the element to get

element — pointer to returned element

Return Values

Returns TRUE if operation is a success; FALSE otherwise.

Diagnostics

None

Description

TutPtrAryGetItemAtIndex returns the element stored in the array at the specified index. Pointer arrays have a zero-based index.

Caution

If index is outside of legal boundaries (less than zero or greater than array item count minus one), this function returns FALSE, and the value of the element is undefined.

See Also

TutPtrAryGetItemIndex, TutPtrAryGetItemCount

Examples

This example returns an element stored in an array, from a given index:

T_PTR_ARY ptr_ary; 
T_INT4 i, *int_ptr; 
 
/* create the pointer array with initial size of 30 */ 
ptr_ary = TutPtrAryCreate(30); 
 
/* fill it up with 25 entries */ 
for (i = 0; i < 25; i++) { 
  /* allocate the space for the next element */ 
  T_MALLOC(int_ptr, sizeof(T_INT4), T_INT4 *); 
  *int_ptr = i; 
  /* append the item to the array, ignore the index */ 
  TutPtrAryAppend(ptr_ary, int_ptr, NULL); 
}  
/* look up item at index 13 */ 
TutPtrAryGetItemAtIndex(ptr_ary, 13, (T_PTR *)&int_ptr); 
/* after this operation, int_ptr should point to the location that */ 
/* contains number 13 */ 

TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com