Partager via


CArray::RelocateElements

Relocates data to a new buffer when the array should grow or shrink.

template<class TYPE, class ARG_TYPE> 
AFX_INLINE void CArray<TYPE, ARG_TYPE>::RelocateElements( 
   TYPE* pNewData,
   const TYPE* pData,
   INT_PTR nCount 
);

Parameters

  • pNewData
    A new buffer for the array of elements.

  • pData
    The old array of elements.

  • nCount
    Number of elements in the old array.

Remarks

pNewData is always large enough to hold all the pData elements.

The CArray implementation uses this method to copy the old data to a new buffer when the array should grow or shrink (when SetSize or FreeExtra are called). The default implementation just copies the data.

For arrays in which an element contains a pointer to one of its own members, or another structure contains a pointer to one of the array elements, the pointers are not updated in plain copy. In this case, you can correct pointers by implementing a specialization of RelocateElements with the relevant types. You are also responsible for data copying.

Requirements

Header: afxtempl.h

See Also

Concepts

CArray::SetSize

CArray::FreeExtra