DPA_InsertPtr

This function inserts an item into a DPA at a given position.

Declaration

int
DPA_InsertPtr (
    HDPA pdpa,
    int index,
    PVOID p);

Parameters

The pdpa argument provides a handle to the DPA.

The index argument provides the 0-based index at which to insert the item, or is DPA_APPEND (0x7FFFFFFF) to add the item to the end of the list.

The p argument provides a pointer to the item, or is NULL to insert an empty item.

Return Value

The function returns the 0-based index at which the item was added to the list, else DPA_ERR (-1) for failure.

Behaviour

The function inserts the given item into the given DPA at the position described by the given index (subject to one exceptional case noted below). All pointers at or above the insertion point are moved one position further along the array to make room for the new pointer.

The function fails trivially if the DPA handle is NULL or if the 0-based index is negative. If the index is greater than the number of pointers currently in the array, then the function inserts at the end of the array. This case may be arranged most conveniently by giving DPA_APPEND as the index.

If memory for the array is not large enough for one more pointer, the function fails unless it can get a reallocation. The new capacity, measured in pointers, is the current number of pointers in the array, plus one, rounded up to the next multiple of the allocation unit (which may increase as a side-effect).

Early Implementations

Some variations are known for early implementations. Version 4.00 merely assumes that the DPA handle is not NULL. In version 4.70, the function does not fail if the DPA handle is NULL, but instead returns zero.

Availability

The DPA_InsertPtr function is exported from COMCTL32.DLL as ordinal 334 in version 3.50 and higher.

This function was documented among the Settlement Program Interfaces in December 2002, but with Windows 2000 cited as the minimum operating system, despite many years of earlier availability.