mark: Clear marks in some cases, but do not do useless job in free_\*

This commit is contained in:
ZyX
2015-08-16 18:54:41 +03:00
parent be45e75026
commit 22906265a2
3 changed files with 17 additions and 5 deletions

2
.gitignore vendored
View File

@@ -13,6 +13,8 @@
*.o *.o
*.so *.so
tags
/src/nvim/po/vim.pot /src/nvim/po/vim.pot
/src/nvim/po/*.ck /src/nvim/po/*.ck

View File

@@ -557,9 +557,9 @@ static void free_buffer(buf_T *buf)
unref_var_dict(buf->b_vars); unref_var_dict(buf->b_vars);
aubuflocal_remove(buf); aubuflocal_remove(buf);
dict_unref(buf->additional_data); dict_unref(buf->additional_data);
free_fmark(buf->b_last_cursor); clear_fmark(&buf->b_last_cursor);
free_fmark(buf->b_last_insert); clear_fmark(&buf->b_last_insert);
free_fmark(buf->b_last_change); clear_fmark(&buf->b_last_change);
for (size_t i = 0; i < NMARKS; i++) { for (size_t i = 0; i < NMARKS; i++) {
free_fmark(buf->b_namedm[i]); free_fmark(buf->b_namedm[i]);
} }
@@ -569,6 +569,8 @@ static void free_buffer(buf_T *buf)
if (autocmd_busy) { if (autocmd_busy) {
// Do not free the buffer structure while autocommands are executing, // Do not free the buffer structure while autocommands are executing,
// it's still needed. Free it when autocmd_busy is reset. // it's still needed. Free it when autocmd_busy is reset.
memset(&buf->b_namedm[0], 0, sizeof(buf->b_namedm));
memset(&buf->b_changelist[0], 0, sizeof(buf->b_changelist));
buf->b_next = au_pending_free_buf; buf->b_next = au_pending_free_buf;
au_pending_free_buf = buf; au_pending_free_buf = buf;
} else { } else {

View File

@@ -73,17 +73,23 @@ int setmark(int c)
void free_fmark(fmark_T fm) void free_fmark(fmark_T fm)
{ {
dict_unref(fm.additional_data); dict_unref(fm.additional_data);
fm.additional_data = NULL;
} }
/// Free xfmark_T item /// Free xfmark_T item
void free_xfmark(xfmark_T fm) void free_xfmark(xfmark_T fm)
{ {
xfree(fm.fname); xfree(fm.fname);
fm.fname = NULL;
free_fmark(fm.fmark); free_fmark(fm.fmark);
} }
/// Free and clear fmark_T item
void clear_fmark(fmark_T *fm)
FUNC_ATTR_NONNULL_ALL
{
free_fmark(*fm);
memset(fm, 0, sizeof(*fm));
}
/* /*
* Set named mark "c" to position "pos". * Set named mark "c" to position "pos".
* When "c" is upper case use file "fnum". * When "c" is upper case use file "fnum".
@@ -1409,6 +1415,7 @@ void free_jumplist(win_T *wp)
for (i = 0; i < wp->w_jumplistlen; ++i) { for (i = 0; i < wp->w_jumplistlen; ++i) {
free_xfmark(wp->w_jumplist[i]); free_xfmark(wp->w_jumplist[i]);
} }
wp->w_jumplistlen = 0;
} }
void set_last_cursor(win_T *win) void set_last_cursor(win_T *win)
@@ -1428,5 +1435,6 @@ void free_all_marks(void)
free_xfmark(namedfm[i]); free_xfmark(namedfm[i]);
} }
} }
memset(&namedfm[0], 0, sizeof(namedfm));
} }
#endif #endif