mark: Make clrallmarks correctly free all marks, and set zero tstamps

This and the previous commit together fix #3472. This one also fixes memory leak
on :delmarks!.
This commit is contained in:
ZyX
2015-10-23 14:42:35 +03:00
parent 7a1090eef5
commit e96aa067f3

View File

@@ -546,19 +546,26 @@ int check_mark(pos_T *pos)
return OK; return OK;
} }
/* /// Clear all marks and change list in the given buffer
* clrallmarks() - clear all marks in the buffer 'buf' ///
* /// Used mainly when trashing the entire buffer during ":e" type commands.
* Used mainly when trashing the entire buffer during ":e" type commands ///
*/ /// @param[out] buf Buffer to clear marks in.
void clrallmarks(buf_T *buf) void clrallmarks(buf_T *const buf)
FUNC_ATTR_NONNULL_ALL
{ {
memset(&(buf->b_namedm[0]), 0, sizeof(buf->b_namedm)); for (size_t i = 0; i < NMARKS; i++) {
buf->b_op_start.lnum = 0; /* start/end op mark cleared */ clear_fmark(&buf->b_namedm[i]);
}
clear_fmark(&buf->b_last_cursor);
buf->b_last_cursor.mark.lnum = 1;
clear_fmark(&buf->b_last_insert);
clear_fmark(&buf->b_last_change);
buf->b_op_start.lnum = 0; // start/end op mark cleared
buf->b_op_end.lnum = 0; buf->b_op_end.lnum = 0;
RESET_FMARK(&buf->b_last_cursor, ((pos_T) {1, 0, 0}), 0); // '" mark for (int i = 0; i < buf->b_changelistlen; i++) {
CLEAR_FMARK(&buf->b_last_insert); // '^ mark clear_fmark(&buf->b_changelist[i]);
CLEAR_FMARK(&buf->b_last_change); // '. mark }
buf->b_changelistlen = 0; buf->b_changelistlen = 0;
} }