Custom Memory Allocation Example
Provides Purify with information about a pending memory allocation. Call this function right before invoking custom memory block allocation code.
size_t PurifyPreAlloc(size_t cbRequest, unsigned int dwFlags)
cbRequest |
The requested block size, within the block's red zones. |
dwFlags |
May include any of the following flags, or 0 to indicate none of them: |
Flag |
Meaning |
PURIFY_TRACK_AS_HEAP |
The block is allocated within a Windows heap |
PURIFY_TRACK_NO_REDZONE |
Purify should not pad the block with red zones |
n |
Where n is the total size (including red zones) of the block to be allocated. |
§ This function supplies Purify with information about a pending memory block allocation. If Purify is tracking the memory block, this function returns the block's actual size for use by your custom allocation code. This actual size value includes the red zones that provide Purify array-bounds detection to any of your code that will use the block after it is allocated. Use this function in conjunction with the PurifyPostAlloc() function, which indicates to Purify that the allocation is complete.
§ This function is a member of Purify's memory tracking interface. The example code provided for Purify's memory tracking interface demonstrates this function.
§ This function is necessary only for custom memory allocation routines. Purify automatically intercepts standard Windows and C runtime allocation API functions.
(C) Copyright IBM Corporation 1992, 2010.