CoGetMalloc

Retrieves a pointer to the default OLE task memory allocator (which supports the system implementation of the IMalloc interface) so applications can call its methods to manage memory.

HRESULT CoGetMalloc(
  DWORD dwMemContext,  //Indicates if memory is private or shared
  LPMALLOC * ppMalloc  //Address of output variable that receives a 
                       // pointer to the memory allocator
);
 

Parameters

dwMemContext
[in] Reserved; value must be 1.
ppMalloc
[out] Address of IMalloc* pointer variable that receives the interface pointer to the memory allocator.

Return Values

This function supports the standard return values E_INVALIDARG and E_OUTOFMEMORY, as well as the following:

S_OK
Indicates the allocator was retrieved successfully.

Remarks

The pointer to the IMalloc interface pointer received through the ppMalloc parameter cannot be used from a remote process—each process must have its own allocator.

QuickInfo

  Windows NT: Use version 3.1 or later.
  Windows: Use Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in objbase.h.
  Import Library: Included as a resource in ole32.dll.

See Also

IMalloc, CoTaskMemAlloc