SafeArrayDestroy

This function destroys an existing array descriptor and all of the data in the array. If objects are stored in the array, Release is called on each object in the array.

At a Glance

Header file: Oleauto.h
Windows CE versions: 2.0 and later

Syntax

HRESULT SafeArrayDestroy( SAFEARRAY FAR * psa);

Parameters

psa

Pointer to an array descriptor created by SafeArrayCreate.

Return Values

One of the values obtained from the returned HRESULT and described in the following table is returned.

Value Description
S_OK Success.
DISP_E_ARRAYISLOCKED The array is currently locked.
E_INVALIDARG The item pointed to by psa is not a safe array descriptor.

Remarks

Passing into this function any invalid and, under some circumstances, NULL pointers will result in unexpected termination of the application.

Example

STDMETHODIMP_(ULONG) CEnumPoint::Release()
{
   if(--m_refs == 0){
      if(m_psa != NULL)
      SafeArrayDestroy(m_psa);
      delete this;
      return 0;
   }
   return m_refs;
}