Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function registers an implementation of the IMallocSpyinterface in OLE, thereafter requiring OLE to call its wrapper methods around every call to the corresponding IMallocmethod. IMallocSpyis defined in OLE to allow developers to debug memory allocations.
Syntax
HRESULT CoRegisterMallocSpy( LPMALLOCSPY pMallocSpy ); |
Parameters
- pMallocSpy
-
[in] Pointer to an instance of the IMallocSpyimplementation.
Return Value
This function supports the standard return value E_INVALIDARG, as well as the following:
- S_OK
-
The IMallocSpyobject is successfully registered.
- CO_E_OBJISREG
-
There is already a registered spy.
Remarks
The CoRegisterMallocSpyfunction registers the IMallocSpyobject, which is used to debug calls to IMallocmethods.
The function calls QueryInterfaceon the pointer pMallocSpyfor the interface IID_IMallocSpy. This is to ensure that pMallocSpyreally points to an implementation of IMallocSpy.
By the rules of OLE, it is expected that a successful call to QueryInterfacehas added a reference (through the AddRefmethod) to the IMallocSpyobject. That is, CoRegisterMallocSpydoes not directly call AddRefon pMallocSpy, but fully expects that the QueryInterfacecall will.
When the IMallocSpyobject is registered, whenever there is a call to one of the IMallocmethods, OLE first calls the corresponding IMallocSpypre-method. Then, after executing the IMallocmethod, OLE calls the corresponding IMallocSpypost-method.
For example, whenever there is a call to IMalloc::Alloc, from whatever source, OLE calls IMallocSpy::PreAlloc, calls IMalloc::Alloc, and after that allocation is completed, calls IMallocSpy::PostAlloc.
To determine whether the platform supports this function, see Determining Supported COM APIs.
Requirements
Header | objbase.h |
Library | ole32.lib |
Windows Embedded CE | Windows CE 3.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |