INtime SDK Help
MPOOL_CONFIG structure
typedef struct _mpool_config
{
    DWORD    tag;
    DWORD    flags;
    BYTE     fill_char; 
    DWORD    blk_size; 
    void *  (*getchunk)(DWORD len);
    DWORD   (*putchunk)(void *);
    void    (*free_error)(MPOOL pool, void * p);
    void    (*internal_error)(MPOOL pool, void * p, char * stag, int itag);
    DWORD   (*alloc_pre)(MPOOL pool, DWORD len);
    void  * (*alloc_post)(MPOOL pool, void * p, DWORD len);
    void  * (*free_pre)(MPOOL pool, void * p, DWORD len);
    void    (*free_post)(MPOOL pool, void * p, DWORD len);
    DWORD   (*validate_pre)(MPOOL pool);
    BOOLEAN    (*validate_post)(MPOOL pool, void * p, DWORD len);
    void    (*check_msg)(MPOOL pool, char * msg);
    void    (*dump)(MPOOL pool, FILE * f, DWORD dump_flags, DWORD type, void * p, DWORD len);
        
} MPOOL_CONFIG;

Fields

tag
Numeric value by which the mpool code recognizes the structure. If this value is changed then any attempt to set the configuration will fail.
flags
MPOOL operation flags.
Flag Description
MPOOL_NOLOCK Do not employ a lock for mutual exclusion
MPOOL_BEST_FIT Use Best Fit algorithm for allocation
MPOOL_FIRST_FIT Use First Fit algorithm for allocation
MPOOL_ZAP Zap buffers when freeing
MPOOL_FILL Fill buffers with pattern "fill_char"
fill_char
Fills buffer with this character after alloc if MPOOL_FILL flag is set.
blk_size
Current block size in pages.
getchunk
Handler to request a memory chunk from the system.
void * (*getchunk)(DWORD len);
len
Number of bytes to allocate in pages.

Returns: pointer to beginning of new chunk. NULL if failure.

putchunk
Handler to return a memory chunk to the system.
DWORD  (*putchunk)(void * p);
p
Pointer to the chunk to free.

Returns: the number of bytes freed.

free_error
Handler to report an error that occurs when freeing a buffer.
void (*free_error)(MPOOL pool, void *p); 
pool
The memory pool associated with the buffer.
p
Pointer to the the buffer being freed.
internal_error
Handler to report an internal error condition.
void (*internal_error)(MPOOL pool, void * p, char * stag, int itag);
pool
The memory pool associated with the error.
p
Pointer to an associated buffer.
stag
A string tag.
itag
An integer tag.
alloc_pre
Handler to possibly adjust the size of an allocation operation. Called just before an actual allocation operation.
DWORD (*alloc_pre)(MPOOL pool, DWORD len);
pool
The memory pool associated with the operation.
len
The requested allocation size.

Returns: a positive length delta. Return 0 in the normal case.

alloc_post
Handler to perform some operation post allocation. Could be used to build data fences or trace allocations.
void *(*alloc_post)(MPOOL pool, void * p, DWORD len);
pool
The memory pool associated with the operation.
p
Pointer to the data buffer.
len
The actual length allocated.

Returns: The buffer or a new position within the buffer. Could return a pointer to user buffer if data fences are built.

free_pre
Handler called just prior to a free operation.
void  * (*free_pre)(MPOOL pool, void * p, DWORD len);
pool
The memory pool associated with the operation.
p
Pointer to the buffer to free.
len
The actual length of the buffer.

Returns: the actual buffer to be release. If data fences are built, this value may be lower than the value returned from alloc_post.

free_post
Handler to ...
void    (*free_post)(MPOOL pool, void * p, DWORD len);
pool
The memory pool associated with the operation.
p
Pointer to the buffer to free.
len
The actual length of the buffer.
validate_pre
Handler to return a delta value to adjust a buffer pointer to the actual buffer start prior to validating a buffer. See mpool_validate_buffer() and alloc_pre().
DWORD  (*validate_pre)(MPOOL pool);
pool
The memory pool associated with the operation.

Returns: ...

validate_post
Handler to perform some operation post validation.
BOOLEAN (*validate_post)(MPOOL pool, void * p, DWORD len);
pool
The memory pool associated with the operation.
p
Pointer to the actual buffer.
len
The actual length of the buffer.

Returns: ...

check_msg
Handler to log a message if mpool_check() fails.
void (*check_msg)(MPOOL pool, char * msg);
pool
The memory pool associated with the operation.
msg
A message generatd by mpool_check().

Returns: ...

dump
Handler to create a formatted log of MPOOL data structures. MPOOL_BUFFER_T is the only type useful for external use.
void (*dump)(MPOOL pool, FILE * f, DWORD flags, DWORD type, void * p, DWORD len);
pool
The memory pool associated with the operation.
f
Handle of the file to dump to. If NULL dump to console.
flags
What operations to perform.
Name Description
MPOOL_DUMP_STATS Dump MPOOL_STATS
MPOOL_DUMP_BLKHDR Dump allocation block header.
MPOOL_DUMP_BUFHDR Dump buffer header
MPOOL_DUMP_BUFFER Dump data buffer
MPOOL_DUMP_ALLOCED Dump allocated items
MPOOL_DUMP_FREED Dump freed items
type
the data type
p
The pointer to the data
len
The length of the data

Requirements

Versions Defined in Include Link to
INtime 4.0 intime/rt/include/crtdbg.h rt.h clib.lib
See Also