mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
merge from dev
This commit is contained in:
commit
063f25ba11
7 changed files with 61 additions and 17 deletions
|
@ -46,6 +46,14 @@ bool test_heap2(void);
|
|||
bool test_stl_allocator1(void);
|
||||
bool test_stl_allocator2(void);
|
||||
|
||||
bool mem_is_zero(uint8_t* p, size_t size) {
|
||||
if (p==NULL) return false;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if (p[i] != 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Main testing
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -232,6 +240,21 @@ int main(void) {
|
|||
}
|
||||
result = ok;
|
||||
};
|
||||
CHECK_BODY("zalloc-aligned-small1") {
|
||||
size_t zalloc_size = MI_SMALL_SIZE_MAX / 2;
|
||||
uint8_t* p = (uint8_t*)mi_zalloc_aligned(zalloc_size, MI_MAX_ALIGN_SIZE * 2);
|
||||
result = mem_is_zero(p, zalloc_size);
|
||||
mi_free(p);
|
||||
};
|
||||
CHECK_BODY("rezalloc_aligned-small1") {
|
||||
size_t zalloc_size = MI_SMALL_SIZE_MAX / 2;
|
||||
uint8_t* p = (uint8_t*)mi_zalloc_aligned(zalloc_size, MI_MAX_ALIGN_SIZE * 2);
|
||||
result = mem_is_zero(p, zalloc_size);
|
||||
zalloc_size *= 3;
|
||||
p = (uint8_t*)mi_rezalloc_aligned(p, zalloc_size, MI_MAX_ALIGN_SIZE * 2);
|
||||
result = result && mem_is_zero(p, zalloc_size);
|
||||
mi_free(p);
|
||||
};
|
||||
|
||||
// ---------------------------------------------------
|
||||
// Reallocation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue