aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32heap.c
diff options
context:
space:
mode:
authorEli Zaretskii2016-02-20 18:59:14 +0200
committerEli Zaretskii2016-02-20 18:59:14 +0200
commitea0b604412d6b33353839640f7d5e5e0b62a45ad (patch)
treea5f65e997c9276f6ae6e788c28d2fc8c9ace5b0c /src/w32heap.c
parentc5f72aa573bc45b82ad6479ae0eba5ffc7916fb9 (diff)
downloademacs-ea0b604412d6b33353839640f7d5e5e0b62a45ad.tar.gz
emacs-ea0b604412d6b33353839640f7d5e5e0b62a45ad.zip
Fix memory reservation on MS-Windows
* src/w32heap.c (mmap_alloc): Reserve memory in 64KB granular units. This avoids leaving gaps in reserved memory regions that no one can use, since memory reservation must produce 64KB-aligned addresses. (Bug#22526)
Diffstat (limited to 'src/w32heap.c')
-rw-r--r--src/w32heap.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/w32heap.c b/src/w32heap.c
index 69706a3a57d..b908169b96c 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -641,12 +641,14 @@ mmap_alloc (void **var, size_t nbytes)
641 advance, and the buffer is enlarged several times as the data is 641 advance, and the buffer is enlarged several times as the data is
642 decompressed on the fly. */ 642 decompressed on the fly. */
643 if (nbytes < MAX_BUFFER_SIZE) 643 if (nbytes < MAX_BUFFER_SIZE)
644 p = VirtualAlloc (NULL, (nbytes * 2), MEM_RESERVE, PAGE_READWRITE); 644 p = VirtualAlloc (NULL, ROUND_UP (nbytes * 2, get_allocation_unit ()),
645 MEM_RESERVE, PAGE_READWRITE);
645 646
646 /* If it fails, or if the request is above 512MB, try with the 647 /* If it fails, or if the request is above 512MB, try with the
647 requested size. */ 648 requested size. */
648 if (p == NULL) 649 if (p == NULL)
649 p = VirtualAlloc (NULL, nbytes, MEM_RESERVE, PAGE_READWRITE); 650 p = VirtualAlloc (NULL, ROUND_UP (nbytes, get_allocation_unit ()),
651 MEM_RESERVE, PAGE_READWRITE);
650 652
651 if (p != NULL) 653 if (p != NULL)
652 { 654 {