aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/memory.c
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-01-07 17:52:53 +0300
committerZyX <kp-pav@yandex.ru>2017-01-07 17:52:53 +0300
commit35416e89bcef1de97881a14dc2d2408144bd8a7f (patch)
tree6a16243181bf264e88a34e1420a0634d27613ab1 /src/nvim/memory.c
parent9a09ffa883ea34d07405af9617201958e5a4c861 (diff)
downloadrneovim-35416e89bcef1de97881a14dc2d2408144bd8a7f.tar.gz
rneovim-35416e89bcef1de97881a14dc2d2408144bd8a7f.tar.bz2
rneovim-35416e89bcef1de97881a14dc2d2408144bd8a7f.zip
memory: Restore entered_free_all_mem functionality
Diffstat (limited to 'src/nvim/memory.c')
-rw-r--r--src/nvim/memory.c15
1 files changed, 10 insertions, 5 deletions
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();