mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 06:59:32 +03:00
clarify return codes of VirtualAlloc (issue #731)
This commit is contained in:
parent
4cb5b45178
commit
3bc577004a
1 changed files with 3 additions and 3 deletions
|
@ -261,7 +261,7 @@ int _mi_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_la
|
||||||
|
|
||||||
int _mi_prim_commit(void* addr, size_t size) {
|
int _mi_prim_commit(void* addr, size_t size) {
|
||||||
void* p = VirtualAlloc(addr, size, MEM_COMMIT, PAGE_READWRITE);
|
void* p = VirtualAlloc(addr, size, MEM_COMMIT, PAGE_READWRITE);
|
||||||
return (p == addr ? 0 : (int)GetLastError());
|
return (p != NULL ? 0 : (int)GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
int _mi_prim_decommit(void* addr, size_t size, bool* needs_recommit) {
|
int _mi_prim_decommit(void* addr, size_t size, bool* needs_recommit) {
|
||||||
|
@ -274,11 +274,11 @@ int _mi_prim_reset(void* addr, size_t size) {
|
||||||
void* p = VirtualAlloc(addr, size, MEM_RESET, PAGE_READWRITE);
|
void* p = VirtualAlloc(addr, size, MEM_RESET, PAGE_READWRITE);
|
||||||
mi_assert_internal(p == addr);
|
mi_assert_internal(p == addr);
|
||||||
#if 1
|
#if 1
|
||||||
if (p == addr && addr != NULL) {
|
if (p != NULL) {
|
||||||
VirtualUnlock(addr,size); // VirtualUnlock after MEM_RESET removes the memory from the working set
|
VirtualUnlock(addr,size); // VirtualUnlock after MEM_RESET removes the memory from the working set
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return (p == addr ? 0 : (int)GetLastError());
|
return (p != NULL ? 0 : (int)GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
int _mi_prim_protect(void* addr, size_t size, bool protect) {
|
int _mi_prim_protect(void* addr, size_t size, bool protect) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue