patch 8.1.0475: memory not freed on exit when quit in autocmd

Problem:    Memory not freed on exit when quit in autocmd.
Solution:   Remember funccal stack when executing autocmd.
diff --git a/src/main.c b/src/main.c
index 5cfec34..d4ff370 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1717,7 +1717,7 @@
 }
 
 /*
- * Check for: [r][e][g][vi|vim|view][diff][ex[im]]
+ * Check for: [r][e][g][vi|vim|view][diff][ex[im]]  (sort of)
  * If the executable name starts with "r" we disable shell commands.
  * If the next character is "e" we run in Easy mode.
  * If the next character is "g" we run the GUI version.
@@ -1788,7 +1788,7 @@
     else if (STRNICMP(initstr, "vim", 3) == 0)
 	initstr += 3;
 
-    /* Catch "[r][g]vimdiff" and "[r][g]viewdiff". */
+    // Catch "[r][g]vimdiff" and "[r][g]viewdiff".
     if (STRICMP(initstr, "diff") == 0)
     {
 #ifdef FEAT_DIFF
@@ -1800,13 +1800,15 @@
 #endif
     }
 
+    // Checking for "ex" here may catch some weir names, such as "vimex" or
+    // "viewex", we assume the user knows that.
     if (STRNICMP(initstr, "ex", 2) == 0)
     {
 	if (STRNICMP(initstr + 2, "im", 2) == 0)
 	    exmode_active = EXMODE_VIM;
 	else
 	    exmode_active = EXMODE_NORMAL;
-	change_compatible(TRUE);	/* set 'compatible' */
+	change_compatible(TRUE);	// set 'compatible'
     }
 }
 
@@ -4188,12 +4190,16 @@
     char_u	*res;
     int		save_dbl = debug_break_level;
     int		save_ro = redir_off;
-    void	*fc = NULL;
+    funccal_entry_T funccal_entry;
+    int		did_save_funccal = FALSE;
 
     /* Evaluate the expression at the toplevel, don't use variables local to
      * the calling function. Except when in debug mode. */
     if (!debug_mode)
-	fc = clear_current_funccal();
+    {
+	save_funccal(&funccal_entry);
+	did_save_funccal = TRUE;
+    }
 
      /* Disable debugging, otherwise Vim hangs, waiting for "cont" to be
       * typed. */
@@ -4210,8 +4216,8 @@
     --emsg_silent;
     if (emsg_silent < 0)
 	emsg_silent = 0;
-    if (fc != NULL)
-	restore_current_funccal(fc);
+    if (did_save_funccal)
+	restore_funccal();
 
     /* A client can tell us to redraw, but not to display the cursor, so do
      * that here. */