merge from dev

This commit is contained in:
Daan Leijen 2022-04-09 13:26:38 -07:00
commit 774d12f12e
3 changed files with 28 additions and 7 deletions

View file

@ -18,6 +18,7 @@ static void test_process_info(void);
static void test_reserved(void);
static void negative_stat(void);
static void alloc_huge(void);
static void test_heap_walk(void);
int main() {
mi_version();
@ -31,7 +32,8 @@ int main() {
// invalid_free();
// test_reserved();
// negative_stat();
alloc_huge();
// alloc_huge();
test_heap_walk();
void* p1 = malloc(78);
void* p2 = malloc(24);
@ -51,8 +53,10 @@ int main() {
//free(p1);
//p2 = malloc(32);
//mi_free(p2);
mi_collect(true);
mi_stats_print(NULL);
//mi_collect(true);
//mi_stats_print(NULL);
// test_process_info();
return 0;
}
@ -189,6 +193,19 @@ static void alloc_huge(void) {
mi_free(p);
}
static bool test_visit(const mi_heap_t* heap, const mi_heap_area_t* area, void* block, size_t block_size, void* arg) {
printf("I'm visiting a block of size %zu, allocated size %zu\n", block_size, mi_usable_size(block));
return true;
}
static void test_heap_walk(void) {
mi_heap_t* heap = mi_heap_new();
//mi_heap_malloc(heap, 2097152);
mi_heap_malloc(heap, 2067152);
mi_heap_malloc(heap, 2097160);
mi_heap_malloc(heap, 24576);
mi_heap_visit_blocks(heap, true, &test_visit, NULL);
}
// ----------------------------
// bin size experiments
@ -360,4 +377,4 @@ static void mi_bins(void) {
last_bsize = bsize;
}
}
#endif
#endif