CHStringArray::SetSize method (chstrarr.h)

[The CHStringArray class is part of the WMI Provider Framework which is now considered in final state, and no further development, enhancements, or updates will be available for non-security related issues affecting these libraries. The MI APIs should be used for all new development.]

The SetSize method establishes the size of an empty or existing array.

Syntax

void  throw(CHeap_Exception) SetSize(
  int nNewSize,
  int nGrowBy
);

Parameters

nNewSize

The new array size (number of elements). The value must be greater than or equal to 0 (zero).

nGrowBy

The minimum number of element slots to allocate if a size increase is necessary.

Return value

This method does not return a value.

Remarks

The SetSize method allocates memory if necessary. If the new size is smaller than the old size, then the array is truncated, and all unused memory is released. For efficiency, call SetSize to set the size of the array before using it. This prevents the need to reallocate and copy the array each time an item is added.

The nGrowBy parameter affects internal memory allocation while the array is growing. Its use never affects the array size as reported by GetSize and GetUpperBound.

Examples

See the example for CHStringArray::GetData.

Requirements

Requirement Value
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header chstrarr.h (include FwCommon.h)
Library FrameDyn.lib
DLL FrameDynOS.dll; FrameDyn.dll

See also

CHStringArray

CHStringArray::GetData

CHStringArray::GetSize

CHStringArray::GetUpperBound