IMallocSpy::PreRealloc

Called just before invoking IMalloc::Alloc.

ULONG PreRealloc(

void * pRequest,
//The pointer the caller is passing to IMalloc::Realloc
ULONG cbRequest,
//The byte count the caller is passing to IMalloc::Realloc
void ** ppNewRequest,
//Points to the actual pointer to be reallocated
BOOL fSpyed
//Whether the original allocation was "spyed"
);

Parameters

pRequest

The pointer the caller is passing to IMalloc::Realloc.

cbRequest

The byte count the caller is passing to IMalloc::Realloc.

ppNewRequest

[out] Points to the actual pointer to be reallocated. This may be different from the pointer in pRequest if the implementation of IMallocSpy::PreRealloc extends or modifies the reallocation. This is an out pointer and should always be stored by PreRealloc.

fSpyed

TRUE if the original allocation was done while the spy was active.

Return Value

The actual byte count to be passed to IMalloc::Realloc.

Comments

The IMallocSpy::PreRealloc implementation may extend and/or modify the allocation to store debug-specific information with the allocation. Thus, the ppNewRequest parameter may differ from pRequest, which the caller is passing to IMalloc::Realloc.

PreRealloc can force memory allocation failure by returning 0, allowing testing to ensure that the application handles allocation failure gracefully in all cases. In this case PostRealloc is not called and Realloc returns NULL. Forcing allocation failure is effective only if cbRequest is not equal to 0. Note that if PreRealloc is forcing failure by returning NULL, PostRealloc is not called. However, if IMalloc::Realloc encounters a real memory failure and returns NULL, PostRealloc is called.

See Also

IMalloc::Realloc, IMallocSpy::PostRealloc, CoRegisterMallocSpy, CoRevokeMallocSpy

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database