IMallocSpy::PreRealloc method

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

pRequest [in]

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

cbRequest [in]

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

ppNewRequest [out]

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.

fSpyed [in]

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

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

 

 

Show: