123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- #define MAX_BACKTRACE (32)
- typedef struct _lub_heap_stackframe lub_heap_context_key_t;
- typedef void (function_t)(void);
- struct _lub_heap_stackframe
- {
- function_t * backtrace[MAX_BACKTRACE];
- };
- typedef struct _lub_heap_leak_stats lub_heap_leak_stats_t;
- struct _lub_heap_leak_stats
- {
- size_t contexts;
- size_t allocs;
- size_t alloc_bytes;
- size_t alloc_overhead;
- size_t leaks;
- size_t leaked_bytes;
- size_t leaked_overhead;
- size_t partials;
- size_t partial_bytes;
- size_t partial_overhead;
- size_t scanned;
- };
- struct _lub_heap_context
- {
-
- lub_heap_t *heap;
-
- lub_bintree_node_t bt_node;
-
- lub_heap_node_t *first_node;
-
- size_t allocs;
-
- size_t alloc_bytes;
-
- size_t alloc_overhead;
-
- size_t leaks;
-
- size_t leaked_bytes;
-
- size_t leaked_overhead;
-
- size_t partials;
-
- size_t partial_bytes;
-
- size_t partial_overhead;
-
- lub_heap_context_key_t key;
- };
- extern unsigned long lub_heap_frame_count;
- typedef struct _lub_heap_leak lub_heap_leak_t;
- struct _lub_heap_leak
- {
- lub_bintree_t m_context_tree;
- lub_bintree_t m_node_tree;
- lub_bintree_t m_clear_node_tree;
- lub_bintree_t m_segment_tree;
- lub_heap_leak_stats_t m_stats;
- lub_dblockpool_t m_context_pool;
- lub_heap_t *m_heap_list;
- };
- extern lub_heap_leak_t *
- lub_heap_leak_instance(void);
- extern void
- lub_heap_leak_release(lub_heap_leak_t *instance);
- extern bool_t
- lub_heap_leak_query_node_tree(void);
- extern bool_t
- lub_heap_leak_query_clear_node_tree(void);
- size_t
- lub_heap_context__get_instanceSize(void);
- extern lub_bintree_compare_fn lub_heap_context_compare;
- extern lub_bintree_getkey_fn lub_heap_context_getkey;
-
- const lub_heap_context_t *
- lub_heap_context_find_or_create(
-
- lub_heap_t *instance,
-
- const stackframe_t * stack
- );
-
- lub_heap_context_t *
- lub_heap_context_find(
-
- const stackframe_t * stack
- );
-
- void
- lub_heap_context_init(
-
- lub_heap_context_t *instance,
-
- lub_heap_t *heap,
-
- const stackframe_t * stack
- );
- void
- lub_heap_context_fini(
-
- lub_heap_context_t *instance
- );
- bool_t
- lub_heap_context_delete(
-
- lub_heap_context_t *instance
- );
- bool_t
- lub_heap_context_add_node(
-
- lub_heap_context_t *instance,
-
- lub_heap_node_t *node,
-
- size_t size
- );
-
- void
- lub_heap_context_remove_node(
-
- lub_heap_context_t *instance,
-
- lub_heap_node_t *node
- );
-
- bool_t
- lub_heap_context_show(
-
- lub_heap_context_t *instance,
-
- lub_heap_show_e how
- );
-
- void
- lub_heap_context_clear(
-
- lub_heap_context_t *instance
- );
- void
- lub_heap_context_insert_node(
- lub_heap_context_t * instance,
- lub_heap_node_t * node
- );
- bool_t
- leaks_is_valid_heap_address(lub_heap_t *instance,
- const void *ptr);
- void
- lub_heap_leak_mutex_lock(void);
- void
- lub_heap_leak_mutex_unlock(void);
|