Compartir a través de


IMallocSpy::PreFree

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

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
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

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