diff options
-rw-r--r-- | intern/guardedalloc/intern/mallocn_guarded_impl.c | 6 | ||||
-rw-r--r-- | intern/guardedalloc/intern/mallocn_lockfree_impl.c | 6 | ||||
-rw-r--r-- | intern/guardedalloc/intern/mmap_win.c | 1 |
3 files changed, 13 insertions, 0 deletions
diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c index 92392ce4dd3..9aa140d824c 100644 --- a/intern/guardedalloc/intern/mallocn_guarded_impl.c +++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c @@ -541,6 +541,12 @@ void *MEM_guarded_mapallocN(size_t len, const char *str) { MemHead *memh; + /* on 64 bit, simply use calloc instead, as mmap does not support + * allocating > 4 GB on Windows. the only reason mapalloc exists + * is to get around address space limitations in 32 bit OSes. */ + if(sizeof(void*) >= 8) + return MEM_lockfree_callocN(len, str); + len = SIZET_ALIGN_4(len); #if defined(WIN32) diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.c b/intern/guardedalloc/intern/mallocn_lockfree_impl.c index 44f51a34134..2c7c087966a 100644 --- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c +++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c @@ -265,6 +265,12 @@ void *MEM_lockfree_mapallocN(size_t len, const char *str) { MemHead *memh; + /* on 64 bit, simply use calloc instead, as mmap does not support + * allocating > 4 GB on Windows. the only reason mapalloc exists + * is to get around address space limitations in 32 bit OSes. */ + if(sizeof(void*) >= 8) + return MEM_lockfree_callocN(len, str); + len = SIZET_ALIGN_4(len); #if defined(WIN32) diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c index 3096c589101..4f65c0a742f 100644 --- a/intern/guardedalloc/intern/mmap_win.c +++ b/intern/guardedalloc/intern/mmap_win.c @@ -129,6 +129,7 @@ void *mmap(void *UNUSED(start), size_t len, int prot, int flags, int fd, off_t o } } + /* note len is passed to a 32 bit DWORD, so can't be > 4 GB */ maphandle = CreateFileMapping(fhandle, NULL, prot_flags, 0, len, NULL); if (maphandle == 0) { errno = EBADF; |