Called just before invoking IMalloc::Free.

  • oid * PreFree(

void * pRequest,
//The pointer is passing to IMalloc::Free
BOOL fSpyed
//TRUE if this memory was allocated while the spy was active



The pointer to the block of memory that the caller is passing to IMalloc::Free.


The value is 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.


If the PreAlloc method modified the original allocation, PreFree needs to compute the actual pointer to be passed to IMalloc::Free. For example, if the PreAlloc/PostAlloc pair attached a header used to store debug information to the beginning of the user's allocation, then PreFree would return a pointer to this header so the true allocation block would be freed.

See Also

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

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples