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;
tag
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
blk_size
getchunk
void * (*getchunk)(DWORD len);
len
- Number of bytes to allocate in pages.
Returns: pointer to beginning of new chunk. NULL if failure.
putchunk
DWORD (*putchunk)(void * p);
p
- Pointer to the chunk to free.
Returns: the number of bytes freed.
free_error
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
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
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
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
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
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
DWORD (*validate_pre)(MPOOL pool);
pool
- The memory pool associated with the operation.
Returns: ...
validate_post
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
void (*check_msg)(MPOOL pool, char * msg);
pool
- The memory pool associated with the operation.
msg
- A message generatd by mpool_check().
Returns: ...
dump
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
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 4.0 | intime/rt/include/crtdbg.h | rt.h | clib.lib |