CLISH  0.7.3
heap.h
1 /*
2  * heap.h
3  */
108 #ifndef _lub_heap_h
109 #define _lub_heap_h
110 #include <stddef.h>
111 
112 #include "lub/types.h"
113 #include "lub/c_decl.h"
114 _BEGIN_C_DECL
115 
119 typedef struct lub_heap_s lub_heap_t;
120 
124 typedef struct lub_heap_free_block_s lub_heap_free_block_t;
125 
129 typedef struct lub_heap_stats_s lub_heap_stats_t;
131 {
132  /*----------------------------------------------------- */
136  size_t segs;
140  size_t segs_bytes;
145  /*----------------------------------------------------- */
150  size_t free_blocks;
154  size_t free_bytes;
159  /*----------------------------------------------------- */
164  size_t alloc_blocks;
169  size_t alloc_bytes;
174  /*----------------------------------------------------- */
185  /*----------------------------------------------------- */
216  /*----------------------------------------------------- */
226  size_t static_bytes;
232  /*----------------------------------------------------- */
233 };
238 typedef enum
239 {
264 
265 typedef struct {void *ptr;} struct_void_ptr;
270 typedef enum
271 {
380  LUB_HEAP_ALIGN_2_POWER_27 = 0x08000000
382 
386 typedef enum
387 {
403 
408 typedef void
413  void *block,
417  unsigned index,
421  size_t size,
425  void *arg);
426 
443 void
448  lub_heap_t *instance,
457  void *arg);
474 void
479  lub_heap_t *instance,
488  void *arg);
489 
506 lub_heap_t *
512  void *start,
516  size_t size
517  );
534 void
539  lub_heap_t *instance
540  );
558 void
563  lub_heap_t *instance,
567  void *start,
571  size_t size
572  );
592 void *
597  lub_heap_t *instance,
601  size_t size
602  );
632  lub_heap_t *instance,
637  char **ptr,
641  size_t size,
645  lub_heap_align_t alignment
646  );
671 bool_t
676  bool_t enable
677  );
692 bool_t
717 bool_t
722  bool_t enable
723  );
724 
739 bool_t
741 
757 extern bool_t
759 
765 void
770  lub_heap_status_t status,
774  char *old_ptr,
778  size_t new_size
779  );
780 
792 void
797  lub_heap_t *instance,
801  lub_heap_stats_t *stats
802  );
803 
807 void
812  lub_heap_t *instance,
816  bool_t verbose
817  );
830 size_t
835  lub_heap_t *instance
836  );
837 
838 extern size_t
839  lub_heap__get_block_overhead(lub_heap_t *instance,
840  const void *ptr);
841 
842 extern size_t
843  lub_heap__get_block_size(lub_heap_t *instance,
844  const void *ptr);
852 extern void
868 extern bool_t
873  lub_heap_show_e how,
878  const char *substring
879  );
880 
881 void
886  unsigned framecount
887  );
888 
889 unsigned
890  lub_heap__get_framecount(void);
891 
892 extern bool_t
893  lub_heap_validate_pointer(lub_heap_t *instance,
894  char *ptr);
901 #define LUB_HEAP_ZERO_ALLOC ((void*)-1)
902 
918 extern void
924  const char *program_name
925  );
926 
927 
928 #if defined(__CYGWIN__)
929 
934 extern void
935  cygwin_lub_heap_init(const char *file_name);
936 
937 #define lub_heap_init(arg0) cygwin_lub_heap_init(arg0)
938 
939 #endif /* __CYGWIN__ */
961  lub_heap_t *instance,
965  lub_heap_align_t max_block_size,
969  size_t num_max_blocks
970  );
986 void
991  lub_heap_t *instance
992  );
1013 void
1018  lub_heap_t *instance
1019  );
1020 
1036 size_t
1041  lub_heap_align_t max_block_size,
1045  size_t num_max_blocks
1046  );
1047 
1048 
1049 _END_C_DECL
1050 
1051 #endif /* _lub_heap_h */
bool_t lub_heap_is_tainting(void)
void lub_heap_destroy(lub_heap_t *instance)
bool_t lub_heap_check(bool_t enable)
typedef_BEGIN_C_DECL struct lub_heap_s lub_heap_t
Definition: heap.h:119
void lub_heap_leak_scan(void)
bool_t lub_heap_leak_report(lub_heap_show_e how, const char *substring)
void lub_heap_foreach_segment(lub_heap_t *instance, lub_heap_foreach_fn *fn, void *arg)
size_t lub_heap__get_max_free(lub_heap_t *instance)
void lub_heap__get_stats(lub_heap_t *instance, lub_heap_stats_t *stats)
void lub_heap_add_segment(lub_heap_t *instance, void *start, size_t size)
void lub_heap_leak_suppress_detection(lub_heap_t *instance)
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)
lub_heap_align_t
Definition: heap.h:271
void lub_heap__set_framecount(unsigned framecount)
bool_t lub_heap_is_checking(void)
void * lub_heap_static_alloc(lub_heap_t *instance, size_t size)
void lub_heap_init(const char *program_name)
bool_t lub_heap_check_memory(lub_heap_t *instance)
void lub_heap_show(lub_heap_t *instance, bool_t verbose)
lub_heap_status_t
Definition: heap.h:239
void lub_heap_foreach_free_block(lub_heap_t *instance, lub_heap_foreach_fn *fn, void *arg)
void lub_heap_stop_here(lub_heap_status_t status, char *old_ptr, size_t new_size)
lub_heap_status_t lub_heap_cache_init(lub_heap_t *instance, lub_heap_align_t max_block_size, size_t num_max_blocks)
struct lub_heap_free_block_s lub_heap_free_block_t
Definition: heap.h:124
lub_heap_show_e
Definition: heap.h:387
void lub_heap_leak_restore_detection(lub_heap_t *instance)
size_t lub_heap_overhead_size(lub_heap_align_t max_block_size, size_t num_max_blocks)
lub_heap_t * lub_heap_create(void *start, size_t size)
void lub_heap_foreach_fn(void *block, unsigned index, size_t size, void *arg)
Definition: heap.h:409
@ LUB_HEAP_ALIGN_2_POWER_5
Definition: heap.h:292
@ LUB_HEAP_ALIGN_2_POWER_10
Definition: heap.h:312
@ LUB_HEAP_ALIGN_2_POWER_4
Definition: heap.h:288
@ LUB_HEAP_ALIGN_2_POWER_15
Definition: heap.h:332
@ LUB_HEAP_ALIGN_2_POWER_25
Definition: heap.h:372
@ LUB_HEAP_ALIGN_NATIVE
Definition: heap.h:276
@ LUB_HEAP_ALIGN_2_POWER_13
Definition: heap.h:324
@ LUB_HEAP_ALIGN_2_POWER_8
Definition: heap.h:304
@ LUB_HEAP_ALIGN_2_POWER_26
Definition: heap.h:376
@ LUB_HEAP_ALIGN_2_POWER_12
Definition: heap.h:320
@ LUB_HEAP_ALIGN_2_POWER_24
Definition: heap.h:368
@ LUB_HEAP_ALIGN_2_POWER_22
Definition: heap.h:360
@ LUB_HEAP_ALIGN_2_POWER_6
Definition: heap.h:296
@ LUB_HEAP_ALIGN_2_POWER_16
Definition: heap.h:336
@ LUB_HEAP_ALIGN_2_POWER_2
Definition: heap.h:280
@ LUB_HEAP_ALIGN_2_POWER_21
Definition: heap.h:356
@ LUB_HEAP_ALIGN_2_POWER_19
Definition: heap.h:348
@ LUB_HEAP_ALIGN_2_POWER_20
Definition: heap.h:352
@ LUB_HEAP_ALIGN_2_POWER_3
Definition: heap.h:284
@ LUB_HEAP_ALIGN_2_POWER_18
Definition: heap.h:344
@ LUB_HEAP_ALIGN_2_POWER_27
Definition: heap.h:380
@ LUB_HEAP_ALIGN_2_POWER_9
Definition: heap.h:308
@ LUB_HEAP_ALIGN_2_POWER_11
Definition: heap.h:316
@ LUB_HEAP_ALIGN_2_POWER_17
Definition: heap.h:340
@ LUB_HEAP_ALIGN_2_POWER_7
Definition: heap.h:300
@ LUB_HEAP_ALIGN_2_POWER_23
Definition: heap.h:364
@ LUB_HEAP_ALIGN_2_POWER_14
Definition: heap.h:328
@ LUB_HEAP_FAILED
Definition: heap.h:247
@ LUB_HEAP_INVALID_POINTER
Definition: heap.h:262
@ LUB_HEAP_OK
Definition: heap.h:243
@ LUB_HEAP_DOUBLE_FREE
Definition: heap.h:252
@ LUB_HEAP_CORRUPTED
Definition: heap.h:257
@ LUB_HEAP_SHOW_LEAKS
Definition: heap.h:392
@ LUB_HEAP_SHOW_ALL
Definition: heap.h:401
@ LUB_HEAP_SHOW_PARTIALS
Definition: heap.h:397
bool_t
Definition: types.h:19
Definition: heap.h:131
size_t free_overhead
Definition: heap.h:158
size_t free_bytes
Definition: heap.h:154
size_t alloc_hightide_overhead
Definition: heap.h:201
size_t free_hightide_bytes
Definition: heap.h:210
size_t alloc_bytes
Definition: heap.h:169
size_t free_hightide_overhead
Definition: heap.h:215
size_t alloc_hightide_blocks
Definition: heap.h:190
size_t alloc_total_blocks
Definition: heap.h:179
size_t segs_bytes
Definition: heap.h:140
size_t alloc_blocks
Definition: heap.h:164
size_t alloc_hightide_bytes
Definition: heap.h:196
size_t static_overhead
Definition: heap.h:231
size_t free_blocks
Definition: heap.h:150
size_t free_hightide_blocks
Definition: heap.h:206
size_t segs
Definition: heap.h:136
size_t static_bytes
Definition: heap.h:226
size_t segs_overhead
Definition: heap.h:144
size_t static_blocks
Definition: heap.h:221
size_t alloc_total_bytes
Definition: heap.h:184
size_t alloc_overhead
Definition: heap.h:173
Definition: heap.h:265