IMallocSpy::PreRealloc method (objidl.h)

Performs operations required before calling IMalloc::Realloc.

Syntax

SIZE_T PreRealloc(
  [in]  void   *pRequest,
  [in]  SIZE_T cbRequest,
  [out] void   **ppNewRequest,
  [in]  BOOL   fSpyed
);

Parameters

[in] pRequest

The pointer to the block of memory specified in the call to IMalloc::Realloc.

[in] cbRequest

The byte count of the block of memory as specified in the original call to IMalloc::Realloc.

[out] ppNewRequest

Address of pointer variable that receives a pointer to the memory block to be reallocated. This may be different from the pointer in pRequest if the implementation of PreRealloc extends or modifies the reallocation. This is pointer should always be stored by PreRealloc.

[in] fSpyed

Indicates whether the block of memory was allocated while this spy was active.

Return value

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

Remarks

The 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, a pointer to the request specified in the original call to 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. However, if Realloc encounters a real memory failure and returns NULL, PostRealloc is called. Forcing allocation failure is effective only if cbRequest is not equal to 0.

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

IMallocSpy

IMallocSpy::PostRealloc