fix commit zero on windows
This commit is contained in:
parent
d1bd1644d5
commit
739d11313c
@ -97,8 +97,8 @@ void _mi_block_zero_init(void* p, size_t size) {
|
||||
if (page->flags.is_zero) {
|
||||
((mi_block_t*)p)->next = 0;
|
||||
#if MI_DEBUG>0
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
if (((uint8_t*)p)[i] != 0) {
|
||||
for (size_t i = 0; i < (page->block_size/sizeof(uintptr_t)); i++) {
|
||||
if (((uintptr_t*)p)[i] != 0) {
|
||||
_mi_assert_fail("page not zero", __FILE__, __LINE__, "_mi_block_zero_init");
|
||||
}
|
||||
}
|
||||
|
3
src/os.c
3
src/os.c
@ -601,8 +601,9 @@ static bool mi_os_commitx(void* addr, size_t size, bool commit, bool conservativ
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
*is_zero = true;
|
||||
if (commit) {
|
||||
// if the memory was already committed, the call succeeds but it is not zero'd
|
||||
// *is_zero = true;
|
||||
void* p = VirtualAlloc(start, csize, MEM_COMMIT, PAGE_READWRITE);
|
||||
err = (p == start ? 0 : GetLastError());
|
||||
}
|
||||
|
14
src/page.c
14
src/page.c
@ -81,13 +81,17 @@ static bool mi_page_is_valid_init(mi_page_t* page) {
|
||||
mi_assert_internal(mi_page_list_is_valid(page,page->free));
|
||||
mi_assert_internal(mi_page_list_is_valid(page,page->local_free));
|
||||
|
||||
#if 0
|
||||
if (page->flags.is_zero) {
|
||||
for(mi_block_t* block = page->free; block != NULL; mi_block_next(page,block)) {
|
||||
for (size_t i = sizeof(mi_block_t); i < page->block_size; i++) {
|
||||
mi_assert_internal(0 == *((uint8_t*)block + i));
|
||||
for (size_t i = 1; i < (page->block_size/sizeof(uintptr_t)); i++) {
|
||||
if (((uintptr_t*)block)[i] != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
mi_block_t* tfree = mi_tf_block(page->thread_free);
|
||||
mi_assert_internal(mi_page_list_is_valid(page, tfree));
|
||||
@ -558,7 +562,9 @@ static void mi_page_extend_free(mi_heap_t* heap, mi_page_t* page, mi_stats_t* st
|
||||
_mi_stat_increase(&stats->page_committed, extend * page->block_size);
|
||||
|
||||
// extension into zero initialized memory preserves the zero'd free list
|
||||
if (!page->is_zero_init) page->flags.is_zero = false;
|
||||
if (!page->is_zero_init) {
|
||||
page->flags.is_zero = false;
|
||||
}
|
||||
mi_assert_expensive(mi_page_is_valid_init(page));
|
||||
}
|
||||
|
||||
@ -577,7 +583,7 @@ static void mi_page_init(mi_heap_t* heap, mi_page_t* page, size_t block_size, mi
|
||||
#if MI_SECURE
|
||||
page->cookie = _mi_heap_random(heap) | 1;
|
||||
#endif
|
||||
page->flags.is_zero = page->is_zero_init;
|
||||
page->flags.is_zero = page->is_zero_init;
|
||||
|
||||
mi_assert_internal(page->capacity == 0);
|
||||
mi_assert_internal(page->free == NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user