ListGetDataPtr
void *ListGetDataPtr (ListType list);
Purpose
This function returns a pointer to the memory buffer the list uses to store its items. Since the items are stored contiguously in ascending order, the pointer can be type cast as a pointer to the item type stored in the list and then directly indexed as an array.
This pointer is only valid until the next modification is made to the list.
This function is helpful for use with functions which take arrays of the same item type that the list stores. The following example stores an array of doubles in a list and uses ListGetDataPtr to get a pointer to the list data for use by the YGraphPopup function.
Example Code
#include "toolbox.h"
static ListType list;
static double value;
static int index;
list = ListCreate(sizeof(double));
for (index = 1; index <= 360; index++) {
value = sin (3.1415926 * index / 180);
ListInsertItem (list, &value, END_OF_LIST);
}
YGraphPopup ("Plot Of Data In List", ListGetDataPtr(list),
ListNumItems(list), VAL_DOUBLE);
Parameters
Input | ||
Name | Type | Description |
list | ListType | The list whose list data address will be returned. |
Return Value
Name | Type | Description |
listDataPointer | void * | Returns a pointer the memory where the list's items are stored. |
Additional Information
Library: Programmer's Toolbox
Include file: toolbox\toolbox.h
LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later
Example
Refer to apps\uirview\uirview.cws for an example of using the ListGetDataPtr function.