Share via


IMallocSpy::PreFree (Compact 2013)

3/26/2014

This method is called just before invoking the IMalloc::Free method to ensure that the pointer passed to IMalloc::Free points to the beginning of the actual allocation.

Syntax

void* PreFree(
  void* pRequest, 
  BOOL fSpyed 
);

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, otherwise FALSE. This value is also passed to the IMallocSpy::PostFree method.

Return Value

The actual pointer to pass to IMalloc::Free.

Remarks

If the IMallocSpy::PreAlloc method modified the original allocation request passed to the IMalloc::Alloc method (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 that all of the block that was allocated can be freed.

To determine whether the platform supports this interface, see Determining Supported COM APIs.

Requirements

Header

objidl.h,
objidl.idl

Library

ole32.lib

See Also

Reference

IMallocSpy
CoRegisterMallocSpy
CoRevokeMallocSpy
IMalloc::Alloc
IMalloc::Free
IMalloc::Realloc
IMallocSpy::PostFree
IMallocSpy::PreAlloc