Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

IMallocSpy::PreAlloc method

Performs operations required before calling IMalloc::Alloc.

Syntax


SIZE_T PreAlloc(
  [in] SIZE_T cbRequest
);

Parameters

cbRequest [in]

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

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

ObjIdl.h

IDL

ObjIdl.idl

IID

IID_IMallocSpy is defined as 0000001d-0000-0000-C000-000000000046

See also

IMalloc::Alloc
IMallocSpy
IMallocSpy::PostAlloc

 

 

Community Additions

ADD
Show:
© 2015 Microsoft