Data Structures | |
struct | lub_heap_stats_s |
Defines | |
#define | LUB_HEAP_ZERO_ALLOC ((void*)-1) |
Typedefs | |
typedef lub_heap_s | lub_heap_t |
typedef lub_heap_free_block_s | lub_heap_free_block_t |
typedef lub_heap_stats_s | lub_heap_stats_t |
typedef void | lub_heap_foreach_fn (void *block, unsigned index, size_t size, void *arg) |
Enumerations | |
enum | lub_heap_status_t { LUB_HEAP_OK, LUB_HEAP_FAILED, LUB_HEAP_DOUBLE_FREE, LUB_HEAP_CORRUPTED, LUB_HEAP_INVALID_POINTER } |
enum | lub_heap_align_t { LUB_HEAP_ALIGN_NATIVE = sizeof(struct {void *ptr;}), LUB_HEAP_ALIGN_4 = 0x00000004, LUB_HEAP_ALIGN_8 = 0x00000008, LUB_HEAP_ALIGN_16 = 0x00000010, LUB_HEAP_ALIGN_32 = 0x00000020, LUB_HEAP_ALIGN_64 = 0x00000040, LUB_HEAP_ALIGN_128 = 0x00000080, LUB_HEAP_ALIGN_256 = 0x00000100, LUB_HEAP_ALIGN_512 = 0x00000200, LUB_HEAP_ALIGN_1024 = 0x00000400, LUB_HEAP_ALIGN_2048 = 0x00000800, LUB_HEAP_ALIGN_4096 = 0x00001000, LUB_HEAP_ALIGN_8192 = 0x00002000, LUB_HEAP_ALIGN_16384 = 0x00004000, LUB_HEAP_ALIGN_32768 = 0x00008000 } |
enum | lub_heap_show_e { LUB_HEAP_SHOW_LEAKS, LUB_HEAP_SHOW_PARTIALS, LUB_HEAP_SHOW_ALL } |
Functions | |
void | lub_heap_foreach_segment (lub_heap_t *instance, lub_heap_foreach_fn *fn, void *arg) |
void | lub_heap_foreach_free_block (lub_heap_t *instance, lub_heap_foreach_fn *fn, void *arg) |
lub_heap_t * | lub_heap_create (void *start, size_t size) |
void | lub_heap_add_segment (lub_heap_t *instance, void *start, size_t size) |
void * | lub_heap_static_alloc (lub_heap_t *instance, size_t size) |
lub_heap_status_t | lub_heap_realloc (lub_heap_t *instance, char **ptr, size_t size, lub_heap_align_t alignment) |
bool_t | lub_heap_taint (bool_t enable) |
bool_t | lub_heap_is_tainting (void) |
bool_t | lub_heap_check (bool_t enable) |
bool_t | lub_heap_is_checking (void) |
bool_t | lub_heap_check_memory (lub_heap_t *this) |
void | lub_heap_stop_here (lub_heap_status_t status, char *old_ptr, size_t new_size) |
void | lub_heap__get_stats (lub_heap_t *instance, lub_heap_stats_t *stats) |
void | lub_heap_show (lub_heap_t *instance, bool_t verbose) |
size_t | lub_heap__get_max_free (lub_heap_t *instance) |
size_t | lub_heap__get_block_overhead (void) |
size_t | lub_heap__get_block_size (const void *ptr) |
void | lub_heap_show_leaks (lub_heap_show_e how) |
void | lub_heap__set_framecount (unsigned framecount) |
unsigned | lub_heap__get_framecount (void) |
bool_t | lub_heap_validate_pointer (lub_heap_t *this, char *ptr) |
A client creates an instance of heap; providing it with memory segments to manage. Subsequent operations can then be invoked to obtain memory from those registered segments.
It detects two types of leak by scanning the BSS and DATA segments and identifying any nodes referenced from there. Then each of these referenced nodes is scanned to look for further references.
The heap implements a "best fit" model, for allocation of dynamic memory. This means that free blocks are maintained in size order and hence the most appropriate one can be used to satisfy client requests. This minimises fragmentation of the dynamically allocated memory.
The free blocks are held in a binary tree (using bintree) which provide fast searching for the appropriate block.
|
This 'magic' pointer is returned when a client requests zero bytes The client can see that the allocation has succeeded, but cannot use the "memory" returned. This pointer may be passed transparently back to lub_heap_realloc() without impact. |
|
This type defines a function prototype to be used to iterate around each of a number of things in the system. |
|
This type is used to reference an instance of a free block |
|
This type defines the statistics available for each heap. |
|
This type is used to reference an instance of a heap. |
|
|
This type defines how leak details should be displayed
|
|
This type is used to indicate the result of a dynamic memory allocation
|
|
This method provides the size, in bytes, of the largest allocation which can be performed.
|
|
This operation fills out a statistics structure with the details for the specified heap.
|
|
|
|
This operation augments an existing heap with some more memory to manage.
|
|
This operation controls runtime heap corruption detection. This means that during every heap operation a full check is done of the specified heap, before any allocations/free are performed. This has a performance overhead but provides a valuable aid in finding a memory corrupting client. Corruption will be spotted the first time a memory operation is performed AFTER it has occured. By default checking is switched off.
|
|
This operation checks the integrety of the memory in the specified heap. Corruption will be spotted the first time a check is performed AFTER it has occured.
|
|
This operation creates a dynamic heap from the provided memory segment.
|
|
This operation is a diagnostic which can be used to iterate around all the free blocks in the specified heap. For example it may be desirable to output information about each of the free blocks present.
|
|
This operation is a diagnostic which can be used to iterate around all the segments in the specified heap. For example it may be desirable to output information about each of the segments present.
|
|
This operation indicates the current status of the full memory checking facility.
|
|
This operation indicates the current status of the memory tainting facility
|
|
This operation changes the size of the object referenced by a passed in pointer to "size". The contents will be unchanged up to the minimum of the old and new sizes. If the new size is larger, the new space is uninitialised.
|
|
This operation dumps the salient details of the specified heap to stdout
|
|
This function dumps all the context details for the heap to stdout. how is one of the following values: 0 - show only leaks 1 - show partial leaks (no references to the start of the block) 2 - show all allocations (VERY VERBOSE)
|
|
This operation allocates some "static" memory from a heap. This is memory which will remain allocted for the lifetime of the heap instance. "static" memory allocation has zero overhead and causes zero fragmentation. NB. static allocation are only handed out from the first memory segment
|
|
This function is invoked whenever a call to lub_heap_realloc() fails. It is provided as a debugging aid; simple set a breakpoint to stop execution of the program and any failures will be caught in context.
|
|
This operation controls the tainted memory facility. This means that during certain heap operations memory can be filled with some well defined bit patterns. This causes a slight performance overhead but can be used to shake out bugs such and free-memory-reads and uninitialised-memory-reads By default tainting is switched off.
|