TutPtrAryGetItemCount


Name

TutPtrAryGetItemCount — returns the number of items in a pointer array

Synopsis

T_BOOL TutPtrAryGetItemCount(ptr_ary, count) 
T_PTR_ARY ptr_ary; 
T_INT4 *count; 

Arguments

ptr_ary — pointer array for which the count is returned

count — pointer to number of items in the array

Return Values

Returns TRUE if operation is a success; FALSE if it was passed an invalid pointer array.

Diagnostics

None

Description

TutPtrAryGetItemCount returns the number of elements currently stored in the pointer array. This function does not actually count the elements, so it is very fast.

Caution

Allocate memory for count before calling TutPtrAryGetItemCount.

See Also

TutPtrAryCreate

Examples

This example returns the number of items in the pointer array:

T_PTR_ARY ptr_ary; 
T_INT4 i, *int_ptr, count; 
 
/* 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); 
}  
/* now check and see how many items are there in the array */ 
TutPtrAryGetItemCount(ptr_ary, &count); 
/* at this point, count should contain 25 */ 

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