aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-01-26 18:14:53 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2019-01-27 12:07:06 +0100
commitde16c0bf6445f92f2b6e92ba3253d581e5562178 (patch)
tree7ef2ee67b4328b7e5478a74bfccc6d5ec6eb8d38
parent30bd1c1e85d2fcffa24a87803bec3070e52c7c7e (diff)
downloadrneovim-de16c0bf6445f92f2b6e92ba3253d581e5562178.tar.gz
rneovim-de16c0bf6445f92f2b6e92ba3253d581e5562178.tar.bz2
rneovim-de16c0bf6445f92f2b6e92ba3253d581e5562178.zip
screen: simplify wp->w_lines allocation logic
-rw-r--r--src/nvim/screen.c20
-rw-r--r--src/nvim/window.c27
2 files changed, 7 insertions, 40 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index bb69a13db0..a17688afbc 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -5909,14 +5909,18 @@ void win_grid_alloc(win_T *wp)
grid_invalidate(grid);
}
+ if (grid->Rows != rows) {
+ wp->w_lines_valid = 0;
+ xfree(wp->w_lines);
+ wp->w_lines = xcalloc(rows+1, sizeof(wline_T));
+ }
+
int was_resized = false;
if ((has_allocation != want_allocation)
|| grid->Rows != rows
|| grid->Columns != cols) {
if (want_allocation) {
grid_alloc(grid, rows, cols, true);
- win_free_lsize(wp);
- win_alloc_lines(wp);
} else {
// Single grid mode, all rendering will be redirected to default_grid.
// Only keep track of the size and offset of the window.
@@ -6007,23 +6011,11 @@ retry:
// If anything fails, make grid arrays NULL, so we don't do anything!
// Continuing with the old arrays may result in a crash, because the
// size is wrong.
- FOR_ALL_TAB_WINDOWS(tp, wp) {
- win_free_lsize(wp);
- }
- if (aucmd_win != NULL)
- win_free_lsize(aucmd_win);
grid_alloc(&default_grid, Rows, Columns, !doclear);
StlClickDefinition *new_tab_page_click_defs = xcalloc(
(size_t)Columns, sizeof(*new_tab_page_click_defs));
- FOR_ALL_TAB_WINDOWS(tp, wp) {
- win_alloc_lines(wp);
- }
- if (aucmd_win != NULL && aucmd_win->w_lines == NULL) {
- win_alloc_lines(aucmd_win);
- }
-
clear_tab_page_click_defs(tab_page_click_defs, tab_page_click_defs_size);
xfree(tab_page_click_defs);
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 0edb04f028..91a983e4c7 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -3891,7 +3891,6 @@ static win_T *win_alloc(win_T *after, int hidden)
// allocate window structure and linesizes arrays
win_T *new_wp = xcalloc(1, sizeof(win_T));
- win_alloc_lines(new_wp);
new_wp->handle = ++last_win_id;
handle_register_window(new_wp);
@@ -3972,7 +3971,7 @@ win_free (
}
}
- win_free_lsize(wp);
+ xfree(wp->w_lines);
for (i = 0; i < wp->w_tagstacklen; ++i)
xfree(wp->w_tagstack[i].tagname);
@@ -4120,30 +4119,6 @@ static void frame_remove(frame_T *frp)
/*
- * Allocate w_lines[] for window "wp".
- */
-void win_alloc_lines(win_T *wp)
-{
- wp->w_lines_valid = 0;
- assert(wp->w_height_inner >= 0);
- // TODO(bfredl): this should work, add call to win_set_inner_size?
- // wp->w_lines = xcalloc(wp->w_height_inner+1, sizeof(wline_T));
- wp->w_lines = xcalloc(MAX(wp->w_height_inner + 1, Rows), sizeof(wline_T));
-}
-
-/*
- * free lsize arrays for a window
- */
-void win_free_lsize(win_T *wp)
-{
- // TODO: why would wp be NULL here?
- if (wp != NULL) {
- xfree(wp->w_lines);
- wp->w_lines = NULL;
- }
-}
-
-/*
* Called from win_new_shellsize() after Rows changed.
* This only does the current tab page, others must be done when made active.
*/