comparison src/window.c @ 16825:ce04ebdf26b8 v8.1.1414

patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts commit https://github.com/vim/vim/commit/c799fe206e61f2e2c1231bc46cbe4bb354f3da69 Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 28 23:08:19 2019 +0200 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts Problem: Alloc() returning "char_u *" causes a lot of type casts. Solution: Have it return "void *". (Mike Williams) Define ALLOC_ONE() to check the simple allocations.
author Bram Moolenaar <Bram@vim.org>
date Tue, 28 May 2019 23:15:10 +0200
parents f5487021fdad
children f8e28c6ae8ab
comparison
equal deleted inserted replaced
16824:1f6bb29738d2 16825:ce04ebdf26b8
1063 before = !p_sb; 1063 before = !p_sb;
1064 } 1064 }
1065 if (curfrp->fr_parent == NULL || curfrp->fr_parent->fr_layout != layout) 1065 if (curfrp->fr_parent == NULL || curfrp->fr_parent->fr_layout != layout)
1066 { 1066 {
1067 /* Need to create a new frame in the tree to make a branch. */ 1067 /* Need to create a new frame in the tree to make a branch. */
1068 frp = (frame_T *)alloc_clear(sizeof(frame_T)); 1068 frp = ALLOC_CLEAR_ONE(frame_T);
1069 *frp = *curfrp; 1069 *frp = *curfrp;
1070 curfrp->fr_layout = layout; 1070 curfrp->fr_layout = layout;
1071 frp->fr_parent = curfrp; 1071 frp->fr_parent = curfrp;
1072 frp->fr_next = NULL; 1072 frp->fr_next = NULL;
1073 frp->fr_prev = NULL; 1073 frp->fr_prev = NULL;
3597 * Create a frame for window "wp". 3597 * Create a frame for window "wp".
3598 */ 3598 */
3599 static void 3599 static void
3600 new_frame(win_T *wp) 3600 new_frame(win_T *wp)
3601 { 3601 {
3602 frame_T *frp = (frame_T *)alloc_clear(sizeof(frame_T)); 3602 frame_T *frp = ALLOC_CLEAR_ONE(frame_T);
3603 3603
3604 wp->w_frame = frp; 3604 wp->w_frame = frp;
3605 if (frp != NULL) 3605 if (frp != NULL)
3606 { 3606 {
3607 frp->fr_layout = FR_LEAF; 3607 frp->fr_layout = FR_LEAF;
3632 # ifdef FEAT_GUI 3632 # ifdef FEAT_GUI
3633 int i; 3633 int i;
3634 # endif 3634 # endif
3635 3635
3636 3636
3637 tp = (tabpage_T *)alloc_clear(sizeof(tabpage_T)); 3637 tp = ALLOC_CLEAR_ONE(tabpage_T);
3638 if (tp == NULL) 3638 if (tp == NULL)
3639 return NULL; 3639 return NULL;
3640 3640
3641 # ifdef FEAT_EVAL 3641 # ifdef FEAT_EVAL
3642 /* init t: variables */ 3642 /* init t: variables */
4649 win_T *new_wp; 4649 win_T *new_wp;
4650 4650
4651 /* 4651 /*
4652 * allocate window structure and linesizes arrays 4652 * allocate window structure and linesizes arrays
4653 */ 4653 */
4654 new_wp = (win_T *)alloc_clear(sizeof(win_T)); 4654 new_wp = ALLOC_CLEAR_ONE(win_T);
4655 if (new_wp == NULL) 4655 if (new_wp == NULL)
4656 return NULL; 4656 return NULL;
4657 4657
4658 if (win_alloc_lines(new_wp) == FAIL) 4658 if (win_alloc_lines(new_wp) == FAIL)
4659 { 4659 {
4978 */ 4978 */
4979 int 4979 int
4980 win_alloc_lines(win_T *wp) 4980 win_alloc_lines(win_T *wp)
4981 { 4981 {
4982 wp->w_lines_valid = 0; 4982 wp->w_lines_valid = 0;
4983 wp->w_lines = (wline_T *)alloc_clear(Rows * sizeof(wline_T)); 4983 wp->w_lines = ALLOC_CLEAR_MULT(wline_T, Rows );
4984 if (wp->w_lines == NULL) 4984 if (wp->w_lines == NULL)
4985 return FAIL; 4985 return FAIL;
4986 return OK; 4986 return OK;
4987 } 4987 }
4988 4988
6360 } 6360 }
6361 6361
6362 static void 6362 static void
6363 make_snapshot_rec(frame_T *fr, frame_T **frp) 6363 make_snapshot_rec(frame_T *fr, frame_T **frp)
6364 { 6364 {
6365 *frp = (frame_T *)alloc_clear(sizeof(frame_T)); 6365 *frp = ALLOC_CLEAR_ONE(frame_T);
6366 if (*frp == NULL) 6366 if (*frp == NULL)
6367 return; 6367 return;
6368 (*frp)->fr_layout = fr->fr_layout; 6368 (*frp)->fr_layout = fr->fr_layout;
6369 (*frp)->fr_width = fr->fr_width; 6369 (*frp)->fr_width = fr->fr_width;
6370 (*frp)->fr_height = fr->fr_height; 6370 (*frp)->fr_height = fr->fr_height;
6669 id = wp->w_next_match_id; 6669 id = wp->w_next_match_id;
6670 wp->w_next_match_id++; 6670 wp->w_next_match_id++;
6671 } 6671 }
6672 6672
6673 /* Build new match. */ 6673 /* Build new match. */
6674 m = (matchitem_T *)alloc_clear(sizeof(matchitem_T)); 6674 m = ALLOC_CLEAR_ONE(matchitem_T);
6675 m->id = id; 6675 m->id = id;
6676 m->priority = prio; 6676 m->priority = prio;
6677 m->pattern = pat == NULL ? NULL : vim_strsave(pat); 6677 m->pattern = pat == NULL ? NULL : vim_strsave(pat);
6678 m->hlg_id = hlg_id; 6678 m->hlg_id = hlg_id;
6679 m->match.regprog = regprog; 6679 m->match.regprog = regprog;
7055 7055
7056 FOR_ALL_TAB_WINDOWS(tp, wp) 7056 FOR_ALL_TAB_WINDOWS(tp, wp)
7057 if (wp->w_id == id) 7057 if (wp->w_id == id)
7058 return wp; 7058 return wp;
7059 #ifdef FEAT_TEXT_PROP 7059 #ifdef FEAT_TEXT_PROP
7060 // popup windows are in a separate list 7060 // popup windows are in separate lists
7061 FOR_ALL_TABPAGES(tp) 7061 FOR_ALL_TABPAGES(tp)
7062 for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next) 7062 for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
7063 if (wp->w_id == id) 7063 if (wp->w_id == id)
7064 return wp; 7064 return wp;
7065 for (wp = first_popupwin; wp != NULL; wp = wp->w_next) 7065 for (wp = first_popupwin; wp != NULL; wp = wp->w_next)