mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 22:48:34 +00:00
vim-patch:9.1.0113: duplicate code when cleaning undo stack
Problem: duplicate code when cleaning undo stack
Solution: refactor undo cleanup into a single public function
related: vim/vim#13928
9071ed8107
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
@@ -2988,6 +2988,28 @@ void u_clearall(buf_T *buf)
|
||||
buf->b_u_line_lnum = 0;
|
||||
}
|
||||
|
||||
/// Free all allocated memory blocks for the buffer 'buf'.
|
||||
void u_blockfree(buf_T *buf)
|
||||
{
|
||||
while (buf->b_u_oldhead != NULL) {
|
||||
#ifndef NDEBUG
|
||||
u_header_T *previous_oldhead = buf->b_u_oldhead;
|
||||
#endif
|
||||
|
||||
u_freeheader(buf, buf->b_u_oldhead, NULL);
|
||||
assert(buf->b_u_oldhead != previous_oldhead);
|
||||
}
|
||||
xfree(buf->b_u_line_ptr);
|
||||
}
|
||||
|
||||
/// Free all allocated memory blocks for the buffer 'buf'.
|
||||
/// and invalidate the undo buffer
|
||||
void u_clearallandblockfree(buf_T *buf)
|
||||
{
|
||||
u_blockfree(buf);
|
||||
u_clearall(buf);
|
||||
}
|
||||
|
||||
/// Save the line "lnum" for the "U" command.
|
||||
void u_saveline(buf_T *buf, linenr_T lnum)
|
||||
{
|
||||
@@ -3054,20 +3076,6 @@ void u_undoline(void)
|
||||
check_cursor_col();
|
||||
}
|
||||
|
||||
/// Free all allocated memory blocks for the buffer 'buf'.
|
||||
void u_blockfree(buf_T *buf)
|
||||
{
|
||||
while (buf->b_u_oldhead != NULL) {
|
||||
#ifndef NDEBUG
|
||||
u_header_T *previous_oldhead = buf->b_u_oldhead;
|
||||
#endif
|
||||
|
||||
u_freeheader(buf, buf->b_u_oldhead, NULL);
|
||||
assert(buf->b_u_oldhead != previous_oldhead);
|
||||
}
|
||||
xfree(buf->b_u_line_ptr);
|
||||
}
|
||||
|
||||
/// Allocate memory and copy curbuf line into it.
|
||||
///
|
||||
/// @param lnum the line to copy
|
||||
|
Reference in New Issue
Block a user