summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/edit.c9
-rw-r--r--src/eval.c6
-rw-r--r--src/ex_cmds.c19
-rw-r--r--src/ex_cmds2.c27
-rw-r--r--src/ex_eval.c9
-rw-r--r--src/ex_getln.c30
-rw-r--r--src/gui_gtk_x11.c8
-rw-r--r--src/main.c8
-rw-r--r--src/misc1.c8
-rw-r--r--src/misc2.c186
-rw-r--r--src/option.c38
-rw-r--r--src/os_unix.c19
-rw-r--r--src/proto/diff.pro1
-rw-r--r--src/proto/edit.pro1
-rw-r--r--src/proto/ex_cmds.pro2
-rw-r--r--src/proto/ex_docmd.pro1
-rw-r--r--src/proto/ex_getln.pro1
-rw-r--r--src/proto/getchar.pro1
-rw-r--r--src/proto/mark.pro1
-rw-r--r--src/proto/misc1.pro1
-rw-r--r--src/proto/option.pro2
-rw-r--r--src/proto/quickfix.pro1
-rw-r--r--src/proto/regexp.pro1
-rw-r--r--src/proto/search.pro1
-rw-r--r--src/proto/syntax.pro1
-rw-r--r--src/proto/tag.pro1
-rw-r--r--src/quickfix.c11
-rw-r--r--src/regexp.c12
-rw-r--r--src/search.c9
-rw-r--r--src/spell/de_DE.diff8
-rw-r--r--src/spell/en_AU.diff298
-rw-r--r--src/spell/en_CA.diff319
-rw-r--r--src/spell/en_GB.diff284
-rw-r--r--src/spell/en_US.diff227
-rw-r--r--src/spell/fr_FR.diff24
-rw-r--r--src/spell/nl_NL.diff71
-rw-r--r--src/syntax.c97
-rw-r--r--src/tag.c31
-rw-r--r--src/undo.c4
-rw-r--r--src/version.h4
40 files changed, 1500 insertions, 282 deletions
diff --git a/src/edit.c b/src/edit.c
index ebfe7fd699..c91170215d 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -4985,6 +4985,15 @@ set_last_insert(c)
}
}
+#if defined(EXITFREE) || defined(PROTO)
+ void
+free_last_insert()
+{
+ vim_free(last_insert);
+ last_insert = NULL;
+}
+#endif
+
/*
* Add character "c" to buffer "s". Escape the special meaning of K_SPECIAL
* and CSI. Handle multi-byte characters.
diff --git a/src/eval.c b/src/eval.c
index dc38936aa4..f3e31e2812 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2588,7 +2588,10 @@ eval_for_line(arg, errp, nextcmdp, skip)
{
l = tv.vval.v_list;
if (tv.v_type != VAR_LIST || l == NULL)
+ {
EMSG(_(e_listreq));
+ clear_tv(&tv);
+ }
else
{
fi->fi_list = l;
@@ -2640,7 +2643,10 @@ free_for_info(fi_void)
forinfo_T *fi = (forinfo_T *)fi_void;
if (fi != NULL && fi->fi_list != NULL)
+ {
list_rem_watch(fi->fi_list, &fi->fi_lw);
+ list_unref(fi->fi_list);
+ }
vim_free(fi);
}
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 8346145663..9daa8f671a 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -789,6 +789,16 @@ ex_copy(line1, line2, n)
msgmore((long)count);
}
+static char_u *prevcmd = NULL; /* the previous command */
+
+#if defined(EXITFREE) || defined(PROTO)
+ void
+free_prev_shellcmd()
+{
+ vim_free(prevcmd);
+}
+#endif
+
/*
* Handle the ":!cmd" command. Also for ":r !cmd" and ":w !cmd"
* Bangs in the argument are replaced with the previously entered command.
@@ -807,7 +817,6 @@ do_bang(addr_count, eap, forceit, do_in, do_out)
char_u *arg = eap->arg; /* command */
linenr_T line1 = eap->line1; /* start of range */
linenr_T line2 = eap->line2; /* end of range */
- static char_u *prevcmd = NULL; /* the previous command */
char_u *newcmd = NULL; /* the new command */
int free_newcmd = FALSE; /* need to free() newcmd */
int ins_prevcmd;
@@ -5001,6 +5010,14 @@ write_viminfo_sub_string(fp)
}
#endif /* FEAT_VIMINFO */
+#if defined(EXITFREE) || defined(PROTO)
+ void
+free_old_sub()
+{
+ vim_free(old_sub);
+}
+#endif
+
#if (defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)) || defined(PROTO)
/*
* Set up for a tagpreview.
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index b86e4812ea..45bd2ee63f 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -600,6 +600,7 @@ ex_breakdel(eap)
struct debuggy *bp, *bpi;
int nr;
int todel = -1;
+ int del_all = FALSE;
int i;
linenr_T best_lnum = 0;
@@ -614,6 +615,11 @@ ex_breakdel(eap)
break;
}
}
+ else if (*eap->arg == '*')
+ {
+ todel = 0;
+ del_all = TRUE;
+ }
else
{
/* ":breakdel {func|file} [lnum] {name}" */
@@ -640,15 +646,18 @@ ex_breakdel(eap)
if (todel < 0)
EMSG2(_("E161: Breakpoint not found: %s"), eap->arg);
else
- {
- vim_free(BREAKP(todel).dbg_name);
- vim_free(BREAKP(todel).dbg_prog);
- --dbg_breakp.ga_len;
- if (todel < dbg_breakp.ga_len)
- mch_memmove(&BREAKP(todel), &BREAKP(todel + 1),
- (dbg_breakp.ga_len - todel) * sizeof(struct debuggy));
- ++debug_tick;
- }
+ while (dbg_breakp.ga_len > 0)
+ {
+ vim_free(BREAKP(todel).dbg_name);
+ vim_free(BREAKP(todel).dbg_prog);
+ --dbg_breakp.ga_len;
+ if (todel < dbg_breakp.ga_len)
+ mch_memmove(&BREAKP(todel), &BREAKP(todel + 1),
+ (dbg_breakp.ga_len - todel) * sizeof(struct debuggy));
+ ++debug_tick;
+ if (!del_all)
+ break;
+ }
}
/*
diff --git a/src/ex_eval.c b/src/ex_eval.c
index 485721b9c8..eaa5dec8cb 100644
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -917,8 +917,8 @@ ex_endif(eap)
* Doing this here prevents an exception for a parsing error being
* discarded by throwing the interrupt exception later on.
*/
- if (!(eap->cstack->cs_flags[eap->cstack->cs_idx] & CSF_TRUE) &&
- dbg_check_skipped(eap))
+ if (!(eap->cstack->cs_flags[eap->cstack->cs_idx] & CSF_TRUE)
+ && dbg_check_skipped(eap))
(void)do_intthrow(eap->cstack);
--eap->cstack->cs_idx;
@@ -2108,8 +2108,7 @@ cleanup_conditionals(cstack, searched_cond, inclusive)
* ":return", or ":finish" before the finally clause. We must not
* discard it, unless an error or interrupt occurred afterwards.
*/
- if (did_emsg || got_int ||
- (cstack->cs_flags[idx] & CSF_FINALLY))
+ if (did_emsg || got_int || (cstack->cs_flags[idx] & CSF_FINALLY))
{
switch (cstack->cs_pending[idx])
{
@@ -2194,7 +2193,7 @@ cleanup_conditionals(cstack, searched_cond, inclusive)
* memory used to store it.
*/
if ((cstack->cs_flags[idx] & CSF_TRY)
- && (cstack->cs_flags[idx] & CSF_SILENT))
+ && (cstack->cs_flags[idx] & CSF_SILENT))
{
eslist_T *elem;
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 86da1aa88a..d221249e7e 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -2307,6 +2307,18 @@ realloc_cmdbuff(len)
return OK;
}
+#if defined(FEAT_ARABIC) || defined(PROTO)
+static char_u *arshape_buf = NULL;
+
+# if defined(EXITFREE) || defined(PROTO)
+ void
+free_cmdline_buf()
+{
+ vim_free(arshape_buf);
+}
+# endif
+#endif
+
/*
* Draw part of the cmdline at the current cursor position. But draw stars
* when cmdline_star is TRUE.
@@ -2333,7 +2345,6 @@ draw_cmdline(start, len)
#ifdef FEAT_ARABIC
if (p_arshape && !p_tbidi && enc_utf8 && len > 0)
{
- static char_u *buf;
static int buflen = 0;
char_u *p;
int j;
@@ -2354,10 +2365,10 @@ draw_cmdline(start, len)
{
/* Re-allocate the buffer. We keep it around to avoid a lot of
* alloc()/free() calls. */
- vim_free(buf);
+ vim_free(arshape_buf);
buflen = len * 2;
- buf = alloc(buflen);
- if (buf == NULL)
+ arshape_buf = alloc(buflen);
+ if (arshape_buf == NULL)
return; /* out of memory */
}
@@ -2394,23 +2405,24 @@ draw_cmdline(start, len)
u8c = arabic_shape(u8c, NULL, &u8c_c1, pc, pc1, nc);
- newlen += (*mb_char2bytes)(u8c, buf + newlen);
+ newlen += (*mb_char2bytes)(u8c, arshape_buf + newlen);
if (u8c_c1 != 0)
{
- newlen += (*mb_char2bytes)(u8c_c1, buf + newlen);
+ newlen += (*mb_char2bytes)(u8c_c1, arshape_buf + newlen);
if (u8c_c2 != 0)
- newlen += (*mb_char2bytes)(u8c_c2, buf + newlen);
+ newlen += (*mb_char2bytes)(u8c_c2,
+ arshape_buf + newlen);
}
}
else
{
prev_c = u8c;
- mch_memmove(buf + newlen, p, mb_l);
+ mch_memmove(arshape_buf + newlen, p, mb_l);
newlen += mb_l;
}
}
- msg_outtrans_len(buf, newlen);
+ msg_outtrans_len(arshape_buf, newlen);
}
else
#endif
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 37858dcc89..cd306093dc 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -598,6 +598,14 @@ gui_mch_prepare(int *argc, char **argv)
gui_argv[gui_argc] = NULL;
}
+#if defined(EXITFREE) || defined(PROTO)
+ void
+gui_mch_free_all()
+{
+ vim_free(gui_argv);
+}
+#endif
+
/*
* This should be maybe completely removed.
* Doesn't seem possible, since check_copy_area() relies on
diff --git a/src/main.c b/src/main.c
index 2bed192816..1b64c34354 100644
--- a/src/main.c
+++ b/src/main.c
@@ -104,6 +104,7 @@ main
#endif
int n_commands = 0; /* no. of commands from + or -c */
char_u *commands[MAX_ARG_CMDS]; /* commands from + or -c option */
+ char_u cmds_tofree[MAX_ARG_CMDS]; /* commands that need free() */
#ifdef FEAT_PRECOMMANDS
int p_commands = 0; /* no. of commands from --cmd */
char_u *pre_commands[MAX_ARG_CMDS]; /* commands from --cmd option */
@@ -191,6 +192,8 @@ main
TIME_MSG("GUI prepared");
#endif
+ vim_memset(cmds_tofree, 0, sizeof(cmds_tofree));
+
/* Init the table of Normal mode commands. */
init_normal_cmds();
@@ -930,6 +933,7 @@ main
if (p == NULL)
mch_exit(2);
sprintf((char *)p, "so %s", a);
+ cmds_tofree[n_commands] = TRUE;
commands[n_commands++] = p;
}
else
@@ -2013,7 +2017,11 @@ scripterror:
current_SID = SID_CARG;
#endif
for (i = 0; i < n_commands; ++i)
+ {
do_cmdline_cmd(commands[i]);
+ if (cmds_tofree[i])
+ vim_free(commands[i]);
+ }
sourcing_name = NULL;
#ifdef FEAT_EVAL
current_SID = 0;
diff --git a/src/misc1.c b/src/misc1.c
index 30d7696bd9..87c0f1a0a1 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -3406,6 +3406,14 @@ init_homedir()
}
}
+#if defined(EXITFREE) || defined(PROTO)
+ void
+free_homedir()
+{
+ vim_free(homedir);
+}
+#endif
+
/*
* Expand environment variable with path name.
* "~/" is also expanded, using $HOME. For Unix "~user/" is expanded.
diff --git a/src/misc2.c b/src/misc2.c
index 4fdbc2798a..fd882ff991 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -16,6 +16,10 @@
# include <fcntl.h> /* for chdir() */
#endif
+static char_u *username = NULL; /* cached result of mch_get_user_name() */
+
+static char_u *ff_expand_buffer = NULL; /* used for expanding filenames */
+
#if defined(FEAT_VIRTUALEDIT) || defined(PROTO)
static int coladvance2 __ARGS((pos_T *pos, int addspaces, int finetune, colnr_T wcol));
@@ -922,15 +926,29 @@ do_outofmem_msg(size)
}
#if defined(EXITFREE) || defined(PROTO)
+
+# if defined(FEAT_SEARCHPATH)
+static void free_findfile __ARGS((void));
+# endif
+
/*
* Free everything that we allocated.
* Can be used to detect memory leaks, e.g., with ccmalloc.
- * Doesn't do nearly all that is required...
+ * NOTE: This is tricky! Things are freed that functions depend on. Don't be
+ * surprised if Vim crashes...
+ * Some things can't be freed, esp. things local to a library function.
*/
void
free_all_mem()
{
buf_T *buf, *nextbuf;
+ static int 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)
+ return;
+ entered = TRUE;
++autocmd_block; /* don't want to trigger autocommands here */
@@ -939,20 +957,30 @@ free_all_mem()
spell_free_all();
# endif
-#if defined(FEAT_USR_CMDS)
+# if defined(FEAT_USR_CMDS)
/* Clear user commands (before deleting buffers). */
ex_comclear(NULL);
-#endif
+# endif
# ifdef FEAT_MENU
/* Clear menus. */
do_cmdline_cmd((char_u *)"aunmenu *");
# endif
- /* Clear mappings and abbreviations. */
+ /* Clear mappings, abbreviations, breakpoints. */
do_cmdline_cmd((char_u *)"mapclear");
do_cmdline_cmd((char_u *)"mapclear!");
do_cmdline_cmd((char_u *)"abclear");
+# if defined(FEAT_EVAL)
+ do_cmdline_cmd((char_u *)"breakdel *");
+# endif
+
+# ifdef FEAT_TITLE
+ free_titles();
+# endif
+# if defined(FEAT_SEARCHPATH)
+ free_findfile();
+# endif
/* Obviously named calls. */
# if defined(FEAT_EVAL)
@@ -963,11 +991,44 @@ free_all_mem()
free_all_autocmds();
# endif
clear_termcodes();
+ free_all_options();
+ free_all_marks();
+ alist_clear(&global_alist);
+ free_homedir();
+ free_search_patterns();
+ free_old_sub();
+ free_last_insert();
+ free_prev_shellcmd();
+ free_regexp_stuff();
+ free_tag_stuff();
+ free_cd_dir();
+ set_expr_line(NULL);
+ diff_clear();
+
+ /* Free some global vars. */
+ vim_free(username);
+ vim_free(clip_exclude_prog);
+ vim_free(last_cmdline);
+ vim_free(new_last_cmdline);
+ vim_free(keep_msg);
+ vim_free(ff_expand_buffer);
/* Clear cmdline history. */
p_hi = 0;
init_history();
+#ifdef FEAT_QUICKFIX
+ qf_free_all();
+#endif
+
+ /* Close all script inputs. */
+ close_all_scripts();
+
+#if defined(FEAT_WINDOWS)
+ /* Destroy all windows. Must come before freeing buffers. */
+ win_free_all();
+#endif
+
/* Free all buffers. */
for (buf = firstbuf; buf != NULL; )
{
@@ -979,9 +1040,8 @@ free_all_mem()
buf = firstbuf;
}
-#if defined(FEAT_WINDOWS)
- /* Destroy all windows. */
- win_free_all();
+#ifdef FEAT_ARABIC
+ free_cmdline_buf();
#endif
/* Clear registers. */
@@ -989,6 +1049,10 @@ free_all_mem()
ResetRedobuff();
ResetRedobuff();
+#ifdef FEAT_CLIENTSERVER
+ vim_free(serverDelayedStartName);
+#endif
+
/* highlight info */
free_highlight();
@@ -1006,12 +1070,18 @@ free_all_mem()
eval_clear();
# endif
+ free_termoptions();
+
/* screenlines (can't display anything now!) */
free_screenlines();
#if defined(USE_XSMP)
xsmp_close();
#endif
+#ifdef FEAT_GUI_GTK
+ gui_mch_free_all();
+#endif
+ clear_hl_tables();
vim_free(IObuff);
vim_free(NameBuff);
@@ -3642,11 +3712,9 @@ typedef struct ff_search_ctx_T
char_u **ffsc_stopdirs_v;
#endif
int ffsc_need_dir;
-}ff_search_ctx_T;
-static ff_search_ctx_T *ff_search_ctx = NULL;
+} ff_search_ctx_T;
-/* used for expanding filenames */
-static char_u *ff_expand_buffer = NULL;
+static ff_search_ctx_T *ff_search_ctx = NULL;
/* locally needed functions */
#ifdef FEAT_PATH_EXTRA
@@ -3994,8 +4062,7 @@ vim_findfile_init(path, filename, stopdirs, level, free_visited, need_dir,
ff_expand_buffer[len++] = *wc_part++;
}
ff_expand_buffer[len] = NUL;
- ff_search_ctx->ffsc_wc_path =
- vim_strsave(ff_expand_buffer);
+ ff_search_ctx->ffsc_wc_path = vim_strsave(ff_expand_buffer);
if (ff_search_ctx->ffsc_wc_path == NULL)
goto error_return;
@@ -4085,7 +4152,7 @@ vim_findfile_stopdir(buf)
vim_findfile_cleanup(ctx)
void *ctx;
{
- if (NULL == ctx)
+ if (ctx == NULL)
return;
ff_search_ctx = ctx;
@@ -4452,8 +4519,8 @@ vim_findfile(search_ctx)
* still wildcards left, push the directories for further
* search
*/
- for (i = ctx->ffs_filearray_cur; i < ctx->ffs_filearray_size;
- ++i)
+ for (i = ctx->ffs_filearray_cur;
+ i < ctx->ffs_filearray_size; ++i)
{
if (!mch_isdir(ctx->ffs_filearray[i]))
continue; /* not a directory */
@@ -4474,7 +4541,8 @@ vim_findfile(search_ctx)
*/
if (STRNCMP(ctx->ffs_wc_path, "**", 2) == 0)
{
- for (i = ctx->ffs_filearray_cur; i < ctx->ffs_filearray_size; ++i)
+ for (i = ctx->ffs_filearray_cur;
+ i < ctx->ffs_filearray_size; ++i)
{
if (fnamecmp(ctx->ffs_filearray[i], ctx->ffs_fix_path) == 0)
continue; /* don't repush same directory */
@@ -4875,8 +4943,7 @@ ff_push(ctx)
ff_stack_T *ctx;
{
/* check for NULL pointer, not to return an error to the user, but
- * to prevent a crash
- */
+ * to prevent a crash */
if (ctx != NULL)
{
ctx->ffs_prev = ff_search_ctx->ffsc_stack_ptr;
@@ -5045,6 +5112,18 @@ find_file_in_path(ptr, len, options, first, rel_fname)
FALSE, rel_fname);
}
+static char_u *ff_file_to_find = NULL;
+static void *fdip_search_ctx = NULL;
+
+#if defined(EXITFREE)
+ static void
+free_findfile()
+{
+ vim_free(ff_file_to_find);
+ vim_findfile_cleanup(fdip_search_ctx);
+}
+#endif
+
/*
* Find the directory name "ptr[len]" in the path.
*
@@ -5076,9 +5155,7 @@ find_file_in_path_option(ptr, len, options, first, path_option, need_dir, rel_fn
int need_dir; /* looking for directory name */
char_u *rel_fname; /* file name we are looking relative to. */
{
- static void *search_ctx = NULL;
static char_u *dir;
- static char_u *file_to_find = NULL;
static int did_findfile_init = FALSE;
char_u save_char;
char_u *file_name = NULL;
@@ -5100,33 +5177,33 @@ find_file_in_path_option(ptr, len, options, first, path_option, need_dir, rel_fn
expand_env(ptr, NameBuff, MAXPATHL);
ptr[len] = save_char;
- vim_free(file_to_find);
- file_to_find = vim_strsave(NameBuff);
- if (file_to_find == NULL) /* out of memory */
+ vim_free(ff_file_to_find);
+ ff_file_to_find = vim_strsave(NameBuff);
+ if (ff_file_to_find == NULL) /* out of memory */
{
file_name = NULL;
goto theend;
}
}
- rel_to_curdir = (file_to_find[0] == '.'
- && (file_to_find[1] == NUL
- || vim_ispathsep(file_to_find[1])
- || (file_to_find[1] == '.'
- && (file_to_find[2] == NUL
- || vim_ispathsep(file_to_find[2])))));
- if (vim_isAbsName(file_to_find)
+ rel_to_curdir = (ff_file_to_find[0] == '.'
+ && (ff_file_to_find[1] == NUL
+ || vim_ispathsep(ff_file_to_find[1])
+ || (ff_file_to_find[1] == '.'
+ && (ff_file_to_find[2] == NUL
+ || vim_ispathsep(ff_file_to_find[2])))));
+ if (vim_isAbsName(ff_file_to_find)
/* "..", "../path", "." and "./path": don't use the path_option */
|| rel_to_curdir
#if defined(MSWIN) || defined(MSDOS) || defined(OS2)
/* handle "\tmp" as absolute path */
- || vim_ispathsep(file_to_find[0])
+ || vim_ispathsep(ff_file_to_find[0])
/* handle "c:name" as absulute path */
- || (file_to_find[0] != NUL && file_to_find[1] == ':')
+ || (ff_file_to_find[0] != NUL && ff_file_to_find[1] == ':')
#endif
#ifdef AMIGA
/* handle ":tmp" as absolute path */
- || file_to_find[0] == ':'
+ || ff_file_to_find[0] == ':'
#endif
)
{
@@ -5140,9 +5217,9 @@ find_file_in_path_option(ptr, len, options, first, path_option, need_dir, rel_fn
int l;
int run;
- if (path_with_url(file_to_find))
+ if (path_with_url(ff_file_to_find))
{
- file_name = vim_strsave(file_to_find);
+ file_name = vim_strsave(ff_file_to_find);
goto theend;
}
@@ -5150,7 +5227,7 @@ find_file_in_path_option(ptr, len, options, first, path_option, need_dir, rel_fn
* Otherwise or when this fails use the current directory. */
for (run = 1; run <= 2; ++run)
{
- l = (int)STRLEN(file_to_find);
+ l = (int)STRLEN(ff_file_to_find);
if (run == 1
&& rel_to_curdir
&& (options & FNAME_REL)
@@ -5158,12 +5235,12 @@ find_file_in_path_option(ptr, len, options, first, path_option, need_dir, rel_fn
&& STRLEN(rel_fname) + l < MAXPATHL)
{
STRCPY(NameBuff, rel_fname);
- STRCPY(gettail(NameBuff), file_to_find);
+ STRCPY(gettail(NameBuff), ff_file_to_find);
l = (int)STRLEN(NameBuff);
}
else
{
- STRCPY(NameBuff, file_to_find);
+ STRCPY(NameBuff, ff_file_to_find);
run = 2;
}
@@ -5203,7 +5280,7 @@ find_file_in_path_option(ptr, len, options, first, path_option, need_dir, rel_fn
if (first == TRUE)
{
/* vim_findfile_free_visited can handle a possible NULL pointer */
- vim_findfile_free_visited(search_ctx);
+ vim_findfile_free_visited(fdip_search_ctx);
dir = path_option;
did_findfile_init = FALSE;
}
@@ -5213,7 +5290,7 @@ find_file_in_path_option(ptr, len, options, first, path_option, need_dir, rel_fn
if (did_findfile_init)
{
ff_search_ctx->ffsc_need_dir = need_dir;
- file_name = vim_findfile(search_ctx);
+ file_name = vim_findfile(fdip_search_ctx);
ff_search_ctx->ffsc_need_dir = FALSE;
if (file_name != NULL)
break;
@@ -5228,8 +5305,8 @@ find_file_in_path_option(ptr, len, options, first, path_option, need_dir, rel_fn
{
/* We searched all paths of the option, now we can
* free the search context. */
- vim_findfile_cleanup(search_ctx);
- search_ctx = NULL;
+ vim_findfile_cleanup(fdip_search_ctx);
+ fdip_search_ctx = NULL;
break;
}
@@ -5246,9 +5323,10 @@ find_file_in_path_option(ptr, len, options, first, path_option, need_dir, rel_fn
#else
r_ptr = NULL;
#endif
- search_ctx = vim_findfile_init(buf, file_to_find, r_ptr, 100,
- FALSE, TRUE, search_ctx, FALSE, rel_fname);
- if (search_ctx != NULL)
+ fdip_search_ctx = vim_findfile_init(buf, ff_file_to_find,
+ r_ptr, 100, FALSE, TRUE,
+ fdip_search_ctx, FALSE, rel_fname);
+ if (fdip_search_ctx != NULL)
did_findfile_init = TRUE;
vim_free(buf);
}
@@ -5260,19 +5338,19 @@ find_file_in_path_option(ptr, len, options, first, path_option, need_dir, rel_fn
{
if (need_dir)
EMSG2(_("E344: Can't find directory \"%s\" in cdpath"),
- file_to_find);
+ ff_file_to_find);
else
EMSG2(_("E345: Can't find file \"%s\" in path"),
- file_to_find);
+ ff_file_to_find);
}
else
{
if (need_dir)
EMSG2(_("E346: No more directory \"%s\" found in cdpath"),
- file_to_find);
+ ff_file_to_find);
else
EMSG2(_("E347: No more file \"%s\" found in path"),
- file_to_find);
+ ff_file_to_find);
}
}
@@ -5320,16 +5398,14 @@ get_user_name(buf, len)
char_u *buf;
int len;
{
- static char_u *name = NULL;
-
- if (name == NULL)
+ if (username == NULL)
{
if (mch_get_user_name(buf, len) == FAIL)
return FAIL;
- name = vim_strsave(buf);
+ username = vim_strsave(buf);
}
else
- STRNCPY(buf, name, len);
+ STRNCPY(buf, username, len);
return OK;
}
diff --git a/src/option.c b/src/option.c
index 97c0aa538f..389ab6ea36 100644
--- a/src/option.c
+++ b/src/option.c
@@ -3165,6 +3165,34 @@ set_number_default(name, val)
options[findoption((char_u *)name)].def_val[VI_DEFAULT] = (char_u *)val;
}
+#if defined(EXITFREE) || defined(PROTO)
+/*
+ * Free all options.
+ */
+ void
+free_all_options()
+{
+ int i;
+
+ for (i = 0; !istermoption(&options[i]); i++)
+ {
+ if (options[i].indir == PV_NONE)
+ {
+ /* global option: free value and default value. */
+ if (options[i].flags & P_ALLOCED && options[i].var != NULL)
+ free_string_option(*(char_u **)options[i].var);
+ if (options[i].flags & P_DEF_ALLOCED)
+ free_string_option(options[i].def_val[VI_DEFAULT]);
+ }
+ else if (options[i].var != VAR_WIN
+ && (options[i].flags & P_STRING))
+ /* buffer-local option: free global value */
+ free_string_option(*(char_u **)options[i].var);
+ }
+}
+#endif
+
+
/*
* Initialize the options, part two: After getting Rows and Columns and
* setting 'term'.
@@ -8001,8 +8029,6 @@ put_setbool(fd, cmd, name, value)
void
clear_termoptions()
{
- struct vimoption *p;
-
/*
* Reset a few things before clearing the old options. This may cause
* outputting a few things that the terminal doesn't understand, but the
@@ -8028,6 +8054,14 @@ clear_termoptions()
#endif
stoptermcap(); /* stop termcap mode */
+ free_termoptions();
+}
+
+ void
+free_termoptions()
+{
+ struct vimoption *p;
+
for (p = &options[0]; p->fullname != NULL; p++)
if (istermoption(p))
{
diff --git a/src/os_unix.c b/src/os_unix.c
index d27b05a6d3..07645dc49f 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2703,8 +2703,11 @@ mch_early_init()
void
mch_free_mem()
{
-# if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
- vim_free(signal_stack);
+# if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
+ if (clip_star.owned)
+ clip_lose_selection(&clip_star);
+ if (clip_plus.owned)
+ clip_lose_selection(&clip_plus);
# endif
# if (defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)) || defined(PROTO)
if (xterm_Shell != (Widget)0)
@@ -2714,6 +2717,18 @@ mch_free_mem()
if (app_context != (XtAppContext)NULL)
XtDestroyApplicationContext(app_context);
# endif
+# ifdef FEAT_X11
+ if (x11_display != NULL && x11_display != xterm_dpy)
+ XCloseDisplay(x11_display);
+# endif
+# if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
+ vim_free(signal_stack);
+ signal_stack = NULL;
+# endif
+# ifdef FEAT_TITLE
+ vim_free(oldtitle);
+ vim_free(oldicon);
+# endif
}
#endif
diff --git a/src/proto/diff.pro b/src/proto/diff.pro
index b912a56d6a..b9b33c9e40 100644
--- a/src/proto/diff.pro
+++ b/src/proto/diff.pro
@@ -11,6 +11,7 @@ void ex_diffsplit __ARGS((exarg_T *eap));
void ex_diffthis __ARGS((exarg_T *eap));
void diff_win_options __ARGS((win_T *wp, int addbuf));
void ex_diffoff __ARGS((exarg_T *eap));
+void diff_clear __ARGS((void));
int diff_check __ARGS((win_T *wp, linenr_T lnum));
int diff_check_fill __ARGS((win_T *wp, linenr_T lnum));
void diff_set_topline __ARGS((win_T *fromwin, win_T *towin));
diff --git a/src/proto/edit.pro b/src/proto/edit.pro
index 59939593eb..2168cd8b3e 100644
--- a/src/proto/edit.pro
+++ b/src/proto/edit.pro
@@ -17,6 +17,7 @@ void auto_format __ARGS((int trailblank, int prev_line));
int comp_textwidth __ARGS((int ff));
int stop_arrow __ARGS((void));