aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/eval.c32
-rw-r--r--src/screen.c12
-rw-r--r--src/window.c58
-rw-r--r--src/window.h2
4 files changed, 32 insertions, 72 deletions
diff --git a/src/eval.c b/src/eval.c
index 09e1f8b4aa..9506dd989e 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -6105,23 +6105,21 @@ void set_ref_in_item(typval_T *tv, int copyID)
*/
dict_T *dict_alloc(void)
{
- dict_T *d;
-
- d = (dict_T *)alloc(sizeof(dict_T));
- if (d != NULL) {
- /* Add the dict to the list of dicts for garbage collection. */
- if (first_dict != NULL)
- first_dict->dv_used_prev = d;
- d->dv_used_next = first_dict;
- d->dv_used_prev = NULL;
- first_dict = d;
-
- hash_init(&d->dv_hashtab);
- d->dv_lock = 0;
- d->dv_scope = 0;
- d->dv_refcount = 0;
- d->dv_copyID = 0;
- }
+ dict_T *d = xmalloc(sizeof(dict_T));
+
+ /* Add the dict to the list of dicts for garbage collection. */
+ if (first_dict != NULL)
+ first_dict->dv_used_prev = d;
+ d->dv_used_next = first_dict;
+ d->dv_used_prev = NULL;
+ first_dict = d;
+
+ hash_init(&d->dv_hashtab);
+ d->dv_lock = 0;
+ d->dv_scope = 0;
+ d->dv_refcount = 0;
+ d->dv_copyID = 0;
+
return d;
}
diff --git a/src/screen.c b/src/screen.c
index e40005ebc9..e06da2124a 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -6279,15 +6279,11 @@ retry:
FOR_ALL_TAB_WINDOWS(tp, wp)
{
- if (win_alloc_lines(wp) == FAIL) {
- outofmem = TRUE;
- goto give_up;
- }
+ win_alloc_lines(wp);
+ }
+ if (aucmd_win != NULL && aucmd_win->w_lines == NULL) {
+ win_alloc_lines(aucmd_win);
}
- if (aucmd_win != NULL && aucmd_win->w_lines == NULL
- && win_alloc_lines(aucmd_win) == FAIL)
- outofmem = TRUE;
-give_up:
for (i = 0; i < p_mco; ++i)
if (new_ScreenLinesC[i] == NULL)
diff --git a/src/window.c b/src/window.c
index 8b8ff66ce8..1b0c2013e9 100644
--- a/src/window.c
+++ b/src/window.c
@@ -753,10 +753,6 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
return FAIL;
new_frame(wp);
- if (wp->w_frame == NULL) {
- win_free(wp, NULL);
- return FAIL;
- }
/* make the contents of the new window the same as the current one */
win_init(wp, curwin, flags);
@@ -2755,7 +2751,8 @@ void win_init_empty(win_T *wp)
/*
* Allocate the first window and put an empty buffer in it.
* Called from main().
- * Return FAIL when something goes wrong (out of memory).
+ *
+ * Return FAIL when something goes wrong.
*/
int win_alloc_first(void)
{
@@ -2763,8 +2760,6 @@ int win_alloc_first(void)
return FAIL;
first_tabpage = alloc_tabpage();
- if (first_tabpage == NULL)
- return FAIL;
first_tabpage->tp_topframe = topframe;
curtab = first_tabpage;
@@ -2778,11 +2773,9 @@ int win_alloc_first(void)
void win_alloc_aucmd_win(void)
{
aucmd_win = win_alloc(NULL, TRUE);
- if (aucmd_win != NULL) {
- win_init_some(aucmd_win, curwin);
- RESET_BINDING(aucmd_win);
- new_frame(aucmd_win);
- }
+ win_init_some(aucmd_win, curwin);
+ RESET_BINDING(aucmd_win);
+ new_frame(aucmd_win);
}
/*
@@ -2799,7 +2792,7 @@ static int win_alloc_firstwin(win_T *oldwin)
/* Very first window, need to create an empty buffer for it and
* initialize from scratch. */
curbuf = buflist_new(NULL, NULL, 1L, BLN_LISTED);
- if (curwin == NULL || curbuf == NULL)
+ if (curbuf == NULL)
return FAIL;
curwin->w_buffer = curbuf;
curwin->w_s = &(curbuf->b_s);
@@ -2815,8 +2808,6 @@ static int win_alloc_firstwin(win_T *oldwin)
}
new_frame(curwin);
- if (curwin->w_frame == NULL)
- return FAIL;
topframe = curwin->w_frame;
topframe->fr_width = Columns;
topframe->fr_height = Rows - p_ch;
@@ -2830,7 +2821,7 @@ static int win_alloc_firstwin(win_T *oldwin)
*/
static void new_frame(win_T *wp)
{
- frame_T *frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
+ frame_T *frp = xcalloc(1, sizeof(frame_T));
wp->w_frame = frp;
frp->fr_layout = FR_LEAF;
@@ -2850,21 +2841,13 @@ void win_init_size(void)
/*
* Allocate a new tabpage_T and init the values.
- * Returns NULL when out of memory.
*/
static tabpage_T *alloc_tabpage(void)
{
- tabpage_T *tp;
-
-
- tp = (tabpage_T *)alloc_clear((unsigned)sizeof(tabpage_T));
+ tabpage_T *tp = xcalloc(1, sizeof(tabpage_T));
/* init t: variables */
tp->tp_vars = dict_alloc();
- if (tp->tp_vars == NULL) {
- vim_free(tp);
- return NULL;
- }
init_var_dict(tp->tp_vars, &tp->tp_winvar, VAR_SCOPE);
tp->tp_diff_invalid = TRUE;
@@ -2903,8 +2886,6 @@ int win_new_tabpage(int after)
int n;
newtp = alloc_tabpage();
- if (newtp == NULL)
- return FAIL;
/* Remember the current windows in this Tab page. */
if (leave_tabpage(curbuf, TRUE) == FAIL) {
@@ -3585,25 +3566,14 @@ win_T *buf_jump_open_tab(buf_T *buf)
*/
static win_T *win_alloc(win_T *after, int hidden)
{
- win_T *new_wp;
-
/*
* allocate window structure and linesizes arrays
*/
- new_wp = (win_T *)alloc_clear((unsigned)sizeof(win_T));
-
- if (win_alloc_lines(new_wp) == FAIL) {
- vim_free(new_wp);
- return NULL;
- }
+ win_T *new_wp = xcalloc(1, sizeof(win_T));
+ win_alloc_lines(new_wp);
/* init w: variables */
new_wp->w_vars = dict_alloc();
- if (new_wp->w_vars == NULL) {
- win_free_lsize(new_wp);
- vim_free(new_wp);
- return NULL;
- }
init_var_dict(new_wp->w_vars, &new_wp->w_winvar, VAR_SCOPE);
/* Don't execute autocommands while the window is not properly
@@ -3794,15 +3764,11 @@ static void frame_remove(frame_T *frp)
/*
* Allocate w_lines[] for window "wp".
- * Return FAIL for failure, OK for success.
*/
-int win_alloc_lines(win_T *wp)
+void win_alloc_lines(win_T *wp)
{
wp->w_lines_valid = 0;
- wp->w_lines = (wline_T *)alloc_clear((unsigned)(Rows * sizeof(wline_T)));
- if (wp->w_lines == NULL)
- return FAIL;
- return OK;
+ wp->w_lines = xcalloc(Rows, sizeof(wline_T));
}
/*
diff --git a/src/window.h b/src/window.h
index 27a4f41002..ef2fa5b6d1 100644
--- a/src/window.h
+++ b/src/window.h
@@ -41,7 +41,7 @@ win_T *buf_jump_open_win(buf_T *buf);
win_T *buf_jump_open_tab(buf_T *buf);
void win_append(win_T *after, win_T *wp);
void win_remove(win_T *wp, tabpage_T *tp);
-int win_alloc_lines(win_T *wp);
+void win_alloc_lines(win_T *wp);
void win_free_lsize(win_T *wp);
void shell_new_rows(void);
void shell_new_columns(void);