IMallocSpy::PreAlloc method (objidl.h)

Performs operations required before calling IMalloc::Alloc.

Syntax

SIZE_T PreAlloc(
  [in] SIZE_T cbRequest
);

Parameters

[in] cbRequest

The number of bytes specified in the allocation request the caller is passing to Alloc.

Return value

The number of bytes specified in the call to Alloc, which can be greater than or equal to the value of cbRequest.

Remarks

The 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, IMallocSpy::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, 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.

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::Alloc

IMallocSpy

IMallocSpy::PostAlloc