comparison src/ops.c @ 16768:695d9ef00b03 v8.1.1386

patch 8.1.1386: unessesary type casts for lalloc() commit https://github.com/vim/vim/commit/18a4ba29aeccb9841d5bfdd2eaaffdfae2f15ced Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 24 19:39:03 2019 +0200 patch 8.1.1386: unessesary type casts for lalloc() Problem: Unessesary type casts for lalloc(). Solution: Remove type casts. Change lalloc(size, TRUE) to alloc(size).
author Bram Moolenaar <Bram@vim.org>
date Fri, 24 May 2019 19:45:05 +0200
parents ef00b6bc186b
children fc58fee685e2
comparison
equal deleted inserted replaced
16767:3959544fc067 16768:695d9ef00b03
1158 } 1158 }
1159 get_yank_register(regname, TRUE); 1159 get_yank_register(regname, TRUE);
1160 if (y_append && y_current->y_array != NULL) 1160 if (y_append && y_current->y_array != NULL)
1161 { 1161 {
1162 pp = &(y_current->y_array[y_current->y_size - 1]); 1162 pp = &(y_current->y_array[y_current->y_size - 1]);
1163 lp = lalloc((long_u)(STRLEN(*pp) + STRLEN(p) + 1), TRUE); 1163 lp = alloc(STRLEN(*pp) + STRLEN(p) + 1);
1164 if (lp == NULL) 1164 if (lp == NULL)
1165 { 1165 {
1166 vim_free(p); 1166 vim_free(p);
1167 return FAIL; 1167 return FAIL;
1168 } 1168 }
3055 } 3055 }
3056 3056
3057 y_current->y_size = yanklines; 3057 y_current->y_size = yanklines;
3058 y_current->y_type = yanktype; /* set the yank register type */ 3058 y_current->y_type = yanktype; /* set the yank register type */
3059 y_current->y_width = 0; 3059 y_current->y_width = 0;
3060 y_current->y_array = (char_u **)lalloc_clear((long_u)(sizeof(char_u *) * 3060 y_current->y_array = (char_u **)lalloc_clear(sizeof(char_u *) * yanklines,
3061 yanklines), TRUE); 3061 TRUE);
3062 if (y_current->y_array == NULL) 3062 if (y_current->y_array == NULL)
3063 { 3063 {
3064 y_current = curr; 3064 y_current = curr;
3065 return FAIL; 3065 return FAIL;
3066 } 3066 }
3169 } 3169 }
3170 } 3170 }
3171 3171
3172 if (curr != y_current) /* append the new block to the old block */ 3172 if (curr != y_current) /* append the new block to the old block */
3173 { 3173 {
3174 new_ptr = (char_u **)lalloc((long_u)(sizeof(char_u *) * 3174 new_ptr = (char_u **)alloc(sizeof(char_u *) *
3175 (curr->y_size + y_current->y_size)), TRUE); 3175 (curr->y_size + y_current->y_size));
3176 if (new_ptr == NULL) 3176 if (new_ptr == NULL)
3177 goto fail; 3177 goto fail;
3178 for (j = 0; j < curr->y_size; ++j) 3178 for (j = 0; j < curr->y_size; ++j)
3179 new_ptr[j] = curr->y_array[j]; 3179 new_ptr[j] = curr->y_array[j];
3180 vim_free(curr->y_array); 3180 vim_free(curr->y_array);
3188 3188
3189 /* Concatenate the last line of the old block with the first line of 3189 /* Concatenate the last line of the old block with the first line of
3190 * the new block, unless being Vi compatible. */ 3190 * the new block, unless being Vi compatible. */
3191 if (curr->y_type == MCHAR && vim_strchr(p_cpo, CPO_REGAPPEND) == NULL) 3191 if (curr->y_type == MCHAR && vim_strchr(p_cpo, CPO_REGAPPEND) == NULL)
3192 { 3192 {
3193 pnew = lalloc((long_u)(STRLEN(curr->y_array[curr->y_size - 1]) 3193 pnew = alloc(STRLEN(curr->y_array[curr->y_size - 1])
3194 + STRLEN(y_current->y_array[0]) + 1), TRUE); 3194 + STRLEN(y_current->y_array[0]) + 1);
3195 if (pnew == NULL) 3195 if (pnew == NULL)
3196 { 3196 {
3197 y_idx = y_current->y_size - 1; 3197 y_idx = y_current->y_size - 1;
3198 goto fail; 3198 goto fail;
3199 } 3199 }
4451 return FAIL; 4451 return FAIL;
4452 4452
4453 /* Allocate an array to store the number of spaces inserted before each 4453 /* Allocate an array to store the number of spaces inserted before each
4454 * line. We will use it to pre-compute the length of the new line and the 4454 * line. We will use it to pre-compute the length of the new line and the
4455 * proper placement of each original line in the new one. */ 4455 * proper placement of each original line in the new one. */
4456 spaces = lalloc_clear((long_u)count, TRUE); 4456 spaces = lalloc_clear(count, TRUE);
4457 if (spaces == NULL) 4457 if (spaces == NULL)
4458 return FAIL; 4458 return FAIL;
4459 #if defined(FEAT_COMMENTS) || defined(PROTO) 4459 #if defined(FEAT_COMMENTS) || defined(PROTO)
4460 if (remove_comments) 4460 if (remove_comments)
4461 { 4461 {
4462 comments = (int *)lalloc_clear((long_u)count * sizeof(int), TRUE); 4462 comments = (int *)lalloc_clear(count * sizeof(int), TRUE);
4463 if (comments == NULL) 4463 if (comments == NULL)
4464 { 4464 {
4465 vim_free(spaces); 4465 vim_free(spaces);
4466 return FAIL; 4466 return FAIL;
4467 } 4467 }
4569 if (curbuf->b_has_textprop && !text_prop_frozen) 4569 if (curbuf->b_has_textprop && !text_prop_frozen)
4570 { 4570 {
4571 // Allocate an array to copy the text properties of joined lines into. 4571 // Allocate an array to copy the text properties of joined lines into.
4572 // And another array to store the number of properties in each line. 4572 // And another array to store the number of properties in each line.
4573 prop_lines = (textprop_T **)alloc_clear( 4573 prop_lines = (textprop_T **)alloc_clear(
4574 (int)(count - 1) * sizeof(textprop_T *)); 4574 (count - 1) * sizeof(textprop_T *));
4575 prop_lengths = (int *)alloc_clear((int)(count - 1) * sizeof(int)); 4575 prop_lengths = (int *)alloc_clear((count - 1) * sizeof(int));
4576 if (prop_lengths == NULL) 4576 if (prop_lengths == NULL)
4577 VIM_CLEAR(prop_lines); 4577 VIM_CLEAR(prop_lines);
4578 } 4578 }
4579 #endif 4579 #endif
4580 4580
6598 * Don't want newline character at end of last line if we're in MCHAR mode. 6598 * Don't want newline character at end of last line if we're in MCHAR mode.
6599 */ 6599 */
6600 if (y_ptr->y_type == MCHAR && *len >= eolsize) 6600 if (y_ptr->y_type == MCHAR && *len >= eolsize)
6601 *len -= eolsize; 6601 *len -= eolsize;
6602 6602
6603 p = *str = lalloc(*len + 1, TRUE); /* add one to avoid zero */ 6603 p = *str = alloc(*len + 1); // add one to avoid zero
6604 if (p == NULL) 6604 if (p == NULL)
6605 return -1; 6605 return -1;
6606 lnum = 0; 6606 lnum = 0;
6607 for (i = 0, j = 0; i < (int)*len; i++, j++) 6607 for (i = 0, j = 0; i < (int)*len; i++, j++)
6608 { 6608 {
6816 */ 6816 */
6817 if (y_current->y_type == MLINE || i < y_current->y_size - 1) 6817 if (y_current->y_type == MLINE || i < y_current->y_size - 1)
6818 ++len; 6818 ++len;
6819 } 6819 }
6820 6820
6821 retval = lalloc(len + 1, TRUE); 6821 retval = alloc(len + 1);
6822 6822
6823 /* 6823 /*
6824 * Copy the lines of the yank register into the string. 6824 * Copy the lines of the yank register into the string.
6825 */ 6825 */
6826 if (retval != NULL) 6826 if (retval != NULL)