IMallocSpy::PreFree

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.

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 Values

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

OS Versions: Windows CE 3.0 and later.
Header: Objidl.h, Objidl.idl.
Link Library: Ole32.lib

See Also

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

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.