diff options
Diffstat (limited to 'src/option.c')
-rw-r--r-- | src/option.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/option.c b/src/option.c index 17428ac697..4e40440386 100644 --- a/src/option.c +++ b/src/option.c @@ -2011,8 +2011,11 @@ void set_init_1(void) #endif { #ifdef HAVE_TOTAL_MEM - /* Use amount of memory available to Vim. */ - n = (os_get_total_mem_kib() >> 1); + /* Use half of amount of memory available to Vim. */ + /* If too much to fit in long_u, get long_u max */ + uint64_t available_kib = os_get_total_mem_kib(); + n = available_kib / 2 > ULONG_MAX ? ULONG_MAX + : (long_u)(available_kib /2); #else n = (0x7fffffff >> 11); #endif |