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 
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 {
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
693  lub_heap_is_tainting(void);
717 bool_t
722  bool_t enable
723  );
724 
739 bool_t
740  lub_heap_is_checking(void);
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
853  lub_heap_leak_scan(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__ */
940 
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 */
1052 
Definition: heap.h:316
Definition: heap.h:324
Definition: heap.h:284
Definition: heap.h:308
Definition: heap.h:352
Definition: heap.h:376
size_t segs_bytes
Definition: heap.h:140
Definition: heap.h:280
Definition: heap.h:300
void lub_heap_leak_restore_detection(lub_heap_t *instance)
bool_t lub_heap_check_memory(lub_heap_t *instance)
Definition: heap.h:243
Definition: heap.h:276
struct lub_heap_free_block_s lub_heap_free_block_t
Definition: heap.h:124
size_t alloc_bytes
Definition: heap.h:169
size_t static_overhead
Definition: heap.h:231
void lub_heap_show(lub_heap_t *instance, bool_t verbose)
Definition: heap.h:397
lub_heap_show_e
Definition: heap.h:386
void lub_heap_leak_scan(void)
typedef_BEGIN_C_DECL struct lub_heap_s lub_heap_t
Definition: heap.h:119
bool_t lub_heap_check(bool_t enable)
Definition: heap.h:401
Definition: heap.h:360
Definition: heap.h:292
Definition: heap.h:262
size_t alloc_hightide_blocks
Definition: heap.h:190
Definition: heap.h:340
Definition: heap.h:312
Definition: heap.h:364
Definition: heap.h:348
size_t alloc_blocks
Definition: heap.h:164
bool_t lub_heap_is_checking(void)
Definition: heap.h:304
void * lub_heap_static_alloc(lub_heap_t *instance, size_t size)
Definition: heap.h:252
void lub_heap_foreach_free_block(lub_heap_t *instance, lub_heap_foreach_fn *fn, void *arg)
lub_heap_status_t lub_heap_cache_init(lub_heap_t *instance, lub_heap_align_t max_block_size, size_t num_max_blocks)
size_t static_blocks
Definition: heap.h:221
size_t lub_heap_overhead_size(lub_heap_align_t max_block_size, size_t num_max_blocks)
Definition: heap.h:257
void lub_heap__get_stats(lub_heap_t *instance, lub_heap_stats_t *stats)
Definition: heap.h:372
Definition: heap.h:392
Definition: heap.h:296
size_t segs
Definition: heap.h:136
void lub_heap_stop_here(lub_heap_status_t status, char *old_ptr, size_t new_size)
size_t free_overhead
Definition: heap.h:158
void lub_heap_destroy(lub_heap_t *instance)
bool_t lub_heap_is_tainting(void)
Definition: heap.h:380
Definition: heap.h:328
Definition: heap.h:356
Definition: heap.h:130
size_t alloc_overhead
Definition: heap.h:173
size_t free_bytes
Definition: heap.h:154
lub_heap_t * lub_heap_create(void *start, size_t size)
Definition: heap.h:336
bool_t
Definition: types.h:18
Definition: heap.h:332
size_t alloc_total_blocks
Definition: heap.h:179
size_t segs_overhead
Definition: heap.h:144
void lub_heap_foreach_segment(lub_heap_t *instance, lub_heap_foreach_fn *fn, void *arg)
Definition: heap.h:288
lub_heap_status_t
Definition: heap.h:238
Definition: heap.h:320
void lub_heap_add_segment(lub_heap_t *instance, void *start, size_t size)
void lub_heap__set_framecount(unsigned framecount)
Definition: heap.h:265
bool_t lub_heap_taint(bool_t enable)
size_t lub_heap__get_max_free(lub_heap_t *instance)
Definition: heap.h:344
void lub_heap_leak_suppress_detection(lub_heap_t *instance)
size_t free_hightide_overhead
Definition: heap.h:215
void lub_heap_foreach_fn(void *block, unsigned index, size_t size, void *arg)
Definition: heap.h:409
size_t alloc_hightide_overhead
Definition: heap.h:201
Definition: heap.h:368
size_t alloc_total_bytes
Definition: heap.h:184
size_t free_blocks
Definition: heap.h:150
lub_heap_status_t lub_heap_realloc(lub_heap_t *instance, char **ptr, size_t size, lub_heap_align_t alignment)
void lub_heap_init(const char *program_name)
bool_t lub_heap_leak_report(lub_heap_show_e how, const char *substring)
Definition: heap.h:247
size_t alloc_hightide_bytes
Definition: heap.h:196
size_t free_hightide_blocks
Definition: heap.h:206
size_t free_hightide_bytes
Definition: heap.h:210
size_t static_bytes
Definition: heap.h:226
lub_heap_align_t
Definition: heap.h:270