Skip to content

Commit

Permalink
fix pool commit for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
daanx committed Jun 24, 2019
1 parent 3526b09 commit e5e2b78
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static void* mi_os_page_align_region(void* addr, size_t size, size_t* newsize) {
if (diff <= 0) return NULL;

mi_assert_internal((size_t)diff <= size);
if (newsize != NULL) *newsize = (size_t)diff;
if (newsize != NULL) *newsize = (size_t)diff;
return start;
}

Expand Down Expand Up @@ -177,7 +177,7 @@ static bool mi_os_protectx(void* addr, size_t size, bool protect) {
BOOL ok = VirtualProtect(start,csize,protect ? PAGE_NOACCESS : PAGE_READWRITE,&oldprotect);
err = (ok ? 0 : -1);
#else
err = mprotect(start,csize,protect ? PROT_NONE : (PROT_READ|PROT_WRITE));
err = mprotect(start,csize,protect ? PROT_NONE : (PROT_READ|PROT_WRITE));
#endif
if (err != 0) {
_mi_warning_message("mprotect error: start: 0x%8p, csize: 0x%8zux, errno: %i\n", start, csize, errno);
Expand Down Expand Up @@ -280,7 +280,7 @@ void* _mi_os_alloc_aligned(size_t size, size_t alignment, mi_os_tld_t* tld)
if (((uintptr_t)p % alignment) == 0) mi_stat_increase(tld->stats->mmap_right_align, 1);
}
//fprintf(stderr, "segment address guess: %s, p=%lxu, guess:%lxu\n", (p != NULL && (uintptr_t)p % alignment ==0 ? "correct" : "incorrect"), (uintptr_t)p, next_probable);

if (p==NULL || ((uintptr_t)p % alignment) != 0) {
// if `p` is not yet aligned after all, free the block and use a slower
// but guaranteed way to allocate an aligned block
Expand Down Expand Up @@ -321,7 +321,7 @@ void* _mi_os_alloc_aligned(size_t size, size_t alignment, mi_os_tld_t* tld)
// For now, we disable it on windows as VirtualFree must
// be called on the original allocation and cannot be called
// for individual fragments.
#if !defined(_WIN32) || (MI_INTPTR_SIZE<8)
#if defined(_WIN32) || (MI_INTPTR_SIZE<8)

static void* os_pool_alloc(size_t size, size_t alignment, mi_os_tld_t* tld) {
UNUSED(size);
Expand Down

0 comments on commit e5e2b78

Please sign in to comment.