summaryrefslogtreecommitdiff
path: root/src/misc2.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-06-24 23:07:47 +0000
committerBram Moolenaar <Bram@vim.org>2005-06-24 23:07:47 +0000
commit1ec484f58e9fef3666e80aa835d99a287c155911 (patch)
tree0481a24509748a218d3abb861103c9c385b6f75e /src/misc2.c
parent0a5fe2140db2e6688a7ef42031a21d8293038715 (diff)
downloadvim-git-1ec484f58e9fef3666e80aa835d99a287c155911.tar.gz
updated for version 7.0092
Diffstat (limited to 'src/misc2.c')
-rw-r--r--src/misc2.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/misc2.c b/src/misc2.c
index ace3a907a..4fdbc2798 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -921,6 +921,103 @@ do_outofmem_msg(size)
}
}
+#if defined(EXITFREE) || defined(PROTO)
+/*
+ * Free everything that we allocated.
+ * Can be used to detect memory leaks, e.g., with ccmalloc.
+ * Doesn't do nearly all that is required...
+ */
+ void
+free_all_mem()
+{
+ buf_T *buf, *nextbuf;
+
+ ++autocmd_block; /* don't want to trigger autocommands here */
+
+# if defined(FEAT_SYN_HL)
+ /* Free all spell info. */
+ spell_free_all();
+# endif
+
+#if defined(FEAT_USR_CMDS)
+ /* Clear user commands (before deleting buffers). */
+ ex_comclear(NULL);
+#endif
+
+# ifdef FEAT_MENU
+ /* Clear menus. */
+ do_cmdline_cmd((char_u *)"aunmenu *");
+# endif
+
+ /* Clear mappings and abbreviations. */
+ do_cmdline_cmd((char_u *)"mapclear");
+ do_cmdline_cmd((char_u *)"mapclear!");
+ do_cmdline_cmd((char_u *)"abclear");
+
+ /* Obviously named calls. */
+# if defined(FEAT_EVAL)
+ free_scriptnames();
+ free_all_functions();
+# endif
+# if defined(FEAT_AUTOCMD)
+ free_all_autocmds();
+# endif
+ clear_termcodes();
+
+ /* Clear cmdline history. */
+ p_hi = 0;
+ init_history();
+
+ /* Free all buffers. */
+ for (buf = firstbuf; buf != NULL; )
+ {
+ nextbuf = buf->b_next;
+ close_buffer(NULL, buf, DOBUF_WIPE);
+ if (buf_valid(buf))
+ buf = nextbuf; /* didn't work, try next one */
+ else
+ buf = firstbuf;
+ }
+
+#if defined(FEAT_WINDOWS)
+ /* Destroy all windows. */
+ win_free_all();
+#endif
+
+ /* Clear registers. */
+ clear_registers();
+ ResetRedobuff();
+ ResetRedobuff();
+
+ /* highlight info */
+ free_highlight();
+
+# ifdef UNIX
+ /* Machine-specific free. */
+ mch_free_mem();
+# endif
+
+ /* message history */
+ for (;;)
+ if (delete_first_msg() == FAIL)
+ break;
+
+# ifdef FEAT_EVAL
+ eval_clear();
+# endif
+
+ /* screenlines (can't display anything now!) */
+ free_screenlines();
+
+#if defined(USE_XSMP)
+ xsmp_close();
+#endif
+
+ vim_free(IObuff);
+ vim_free(NameBuff);
+}
+#endif
+
/*
* copy a string into newly allocated memory
*/