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
MFC
TRY
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

AfxSetAllocHook

Sets a hook that enables calling of the specified function before each memory block is allocated.

AFX_ALLOC_HOOK AfxSetAllocHook( 
   AFX_ALLOC_HOOK pfnAllocHook  
);

pfnAllocHook

Specifies the name of the function to call. See the Remarks for the prototype of an allocation function.

Nonzero if you want to permit the allocation; otherwise 0.

The Microsoft Foundation Class Library debug-memory allocator can call a user-defined hook function to allow the user to monitor a memory allocation and to control whether the allocation is permitted. Allocation hook functions are prototyped as follows:

BOOL AFXAPI AllocHook( size_t nSize, BOOL bObject, LONG lRequestNumber );

nSize

The size of the proposed memory allocation.

bObject

TRUE if the allocation is for a CObject-derived object; otherwise FALSE.

lRequestNumber

The memory allocation's sequence number.

Note that the AFXAPI calling convention implies that the callee must remove the parameters from the stack.

Header: afx.h

Community Additions

ADD
Show:
© 2015 Microsoft