IMallocSpy::PreFree

Called just before invoking IMalloc::Free to ensure that the pointer passed to IMalloc::Free points to the beginning of the actual allocation.

void * PreFree(
  void * pRequest,  //Pointer is passing to IMalloc::Free
  BOOL fSpyed       //TRUE if this memory was allocated while the 
                    //spy was active
);
 

Parameters

pRequest
[in] Pointer to the block of memory that the caller is passing to IMalloc::Free.
fSpyed
[in] TRUE if the pRequest parameter of IMallocSpy::PreFree was allocated while the spy was installed. This value is also passed to IMallocSpy::PostFree.

Return Value

The actual pointer to pass to IMalloc::Free.

Remarks

If IMallocSpy::PreAlloc modified the original allocation request passed to IMalloc::Alloc (or IMalloc::Realloc), IMallocSpy::PreFree must supply a pointer to the actual allocation, which COM will pass to IMalloc::Free. For example, if the PreAlloc/PostAlloc pair attached a header used to store debug information to the beginning of the caller's allocation, PreFree must return a pointer to the beginning of this header, so all of the block that was allocated can be freed.

QuickInfo

  Windows NT: Use version 4.0 or later.
  Windows: Use Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in objidl.h.

See Also

IMalloc::Free, IMallocSpy::PostFree, CoRegisterMallocSpy, CoRevokeMallocSpy