SafeArrayAllocData function
Allocates memory for a safe array, based on a descriptor created with SafeArrayAllocDescriptor.
Syntax
HRESULT SafeArrayAllocData( _In_ SAFEARRAY *psa );
Parameters
- psa [in]
-
A safe array descriptor created by SafeArrayAllocDescriptor.
Return value
This function can return one of these values.
| Return code | Description |
|---|---|
|
Success. |
|
The argument psa is not valid. |
|
The array could not be locked. |
Examples
The following example creates a safe array using the SafeArrayAllocDescriptor and SafeArrayAllocData functions.
SAFEARRAY *psa; unsigned int ndim = 2; HRESULT hresult = SafeArrayAllocDescriptor(ndim, &psa); if( FAILED(hresult)) return ERR_OutOfMemory; (psa)->rgsabound[ 0 ].lLbound = 0; (psa)->rgsabound[ 0 ].cElements = 5; (psa)->rgsabound[ 1 ].lLbound = 1; (psa)->rgsabound[ 1 ].cElements = 4; hresult = SafeArrayAllocData(psa); if( FAILED(hresult)) { SafeArrayDestroyDescriptor(psa); return ERR_OutOfMemory; }
Requirements
|
Header |
|
|---|---|
|
Library |
|
|
DLL |
|
Show: