From 35416e89bcef1de97881a14dc2d2408144bd8a7f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 7 Jan 2017 17:52:53 +0300 Subject: memory: Restore entered_free_all_mem functionality --- src/nvim/memory.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/nvim/memory.c') diff --git a/src/nvim/memory.c b/src/nvim/memory.c index 3c0d001848..a5045dfffc 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -48,6 +48,11 @@ MemRealloc mem_realloc = &realloc; # include "memory.c.generated.h" #endif +#ifdef EXITFREE +/// Indicates that free_all_mem function was or is running +bool entered_free_all_mem = false; +#endif + /// Try to free memory. Used when trying to recover from out of memory errors. /// @see {xmalloc} void try_to_free_memory(void) @@ -511,13 +516,13 @@ void time_to_bytes(time_t time_, uint8_t buf[8]) void free_all_mem(void) { buf_T *buf, *nextbuf; - static bool entered = false; - /* When we cause a crash here it is caught and Vim tries to exit cleanly. - * Don't try freeing everything again. */ - if (entered) + // When we cause a crash here it is caught and Vim tries to exit cleanly. + // Don't try freeing everything again. + if (entered_free_all_mem) { return; - entered = true; + } + entered_free_all_mem = true; // Don't want to trigger autocommands from here on. block_autocmds(); -- cgit