MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / alloc_items

Function alloc_items

3rd/mimalloc-2.0.9/test/test-stress.c:92–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92static void* alloc_items(size_t items, random_t r) {
93 if (chance(1, r)) {
94 if (chance(1, r) && allow_large_objects) items *= 50000; // 0.01% giant
95 else if (chance(10, r) && allow_large_objects) items *= 1000; // 0.1% huge
96 else items *= 100; // 1% large objects;
97 }
98 if (items == 40) items++; // pthreads uses that size for stack increases
99 if (use_one_size > 0) items = (use_one_size / sizeof(uintptr_t));
100 if (items==0) items = 1;
101 uintptr_t* p = (uintptr_t*)custom_calloc(items,sizeof(uintptr_t));
102 if (p != NULL) {
103 for (uintptr_t i = 0; i < items; i++) {
104 p[i] = (items - i) ^ cookie;
105 }
106 }
107 return p;
108}
109
110static void free_items(void* p) {
111 if (p != NULL) {

Callers 2

stressFunction · 0.85
leakFunction · 0.85

Calls 1

chanceFunction · 0.85

Tested by

no test coverage detected