Called just prior to invoking IMalloc::Alloc.
ULONG PreAlloc(
ULONG cbRequest //Byte count passed to IMalloc::Alloc
);
The byte count actually passed to IMalloc::Alloc, which should be greater than or equal to the value of cbRequest.
The IMallocSpy::PreAlloc implementation may extend and/or modify the allocation to store debug-specific information with the allocation.
PreAlloc 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, PostAlloc is not called and Alloc returns NULL. Forcing allocation failure is effective only if cbRequest is not equal to 0. If PreAlloc is forcing failure by returning NULL, PostAlloc is not called. However, if IMalloc::Alloc encounters a real memory failure and returns NULL, PostAlloc is called.
The call to PreAlloc through the return from PostAlloc is guaranteed to be thread safe.
Windows NT: Use version 4.0 or later.
Windows: Use Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in objidl.h.
IMalloc::Alloc, IMallocSpy::PostAlloc, CoRegisterMallocSpy, CoRevokeMallocSpy