IMallocSpy::PreFree method (objidl.h)

Performs operations required before calling IMalloc::Free. This method ensures that the pointer passed to Free points to the beginning of the actual allocation.

Syntax

void * PreFree(
  [in] void *pRequest,
  [in] BOOL fSpyed
);

Parameters

[in] pRequest

A pointer to the block of memory that the caller is passing to Free.

[in] fSpyed

Indicates whether the block of memory to be freed was allocated while the current spy was active.

Return value

The value to be passed to IMalloc::Free.

Remarks

If IMallocSpy::PreAlloc modified the original allocation request passed to IMalloc::Alloc (or IMalloc::Realloc), 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.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header objidl.h

See also

IMalloc::Free

IMallocSpy

IMallocSpy::PostFree