diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-05-24 19:39:03 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-05-24 19:39:03 +0200 |
commit | 18a4ba29aeccb9841d5bfdd2eaaffdfae2f15ced (patch) | |
tree | 408ad339f6b34876d2fa481ac61568c7739b1160 | |
parent | 71de720c2c117137185a6fc233b35aab37f0d4bc (diff) | |
download | vim-git-18a4ba29aeccb9841d5bfdd2eaaffdfae2f15ced.tar.gz |
patch 8.1.1386: unessesary type casts for lalloc()v8.1.1386
Problem: Unessesary type casts for lalloc().
Solution: Remove type casts. Change lalloc(size, TRUE) to alloc(size).
41 files changed, 127 insertions, 138 deletions
diff --git a/src/buffer.c b/src/buffer.c index d99071674..f6210952d 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1958,7 +1958,7 @@ buflist_new( } if (buf != curbuf || curbuf == NULL) { - buf = (buf_T *)alloc_clear((unsigned)sizeof(buf_T)); + buf = (buf_T *)alloc_clear(sizeof(buf_T)); if (buf == NULL) { vim_free(ffname); @@ -1985,7 +1985,7 @@ buflist_new( } clear_wininfo(buf); - buf->b_wininfo = (wininfo_T *)alloc_clear((unsigned)sizeof(wininfo_T)); + buf->b_wininfo = (wininfo_T *)alloc_clear(sizeof(wininfo_T)); if ((ffname != NULL && (buf->b_ffname == NULL || buf->b_sfname == NULL)) || buf->b_wininfo == NULL) @@ -2771,7 +2771,7 @@ buflist_setfpos( if (wip == NULL) { /* allocate a new entry */ - wip = (wininfo_T *)alloc_clear((unsigned)sizeof(wininfo_T)); + wip = (wininfo_T *)alloc_clear(sizeof(wininfo_T)); if (wip == NULL) return; wip->wi_win = win; @@ -4911,7 +4911,7 @@ do_arg_all( setpcmark(); opened_len = ARGCOUNT; - opened = alloc_clear((unsigned)opened_len); + opened = alloc_clear(opened_len); if (opened == NULL) return; diff --git a/src/change.c b/src/change.c index d2aa1530f..8f0cacb45 100644 --- a/src/change.c +++ b/src/change.c @@ -282,7 +282,7 @@ f_listener_add(typval_T *argvars, typval_T *rettv) return; } - lnr = (listener_T *)alloc_clear((sizeof(listener_T))); + lnr = (listener_T *)alloc_clear(sizeof(listener_T)); if (lnr == NULL) { free_callback(callback, partial); diff --git a/src/channel.c b/src/channel.c index 1564128ef..4794ae3fa 100644 --- a/src/channel.c +++ b/src/channel.c @@ -294,7 +294,7 @@ static int next_ch_id = 0; add_channel(void) { ch_part_T part; - channel_T *channel = (channel_T *)alloc_clear((int)sizeof(channel_T)); + channel_T *channel = (channel_T *)alloc_clear(sizeof(channel_T)); if (channel == NULL) return NULL; @@ -1728,7 +1728,7 @@ channel_get_all(channel_T *channel, ch_part_T part, int *outlen) // Concatenate everything into one buffer. for (node = head->rq_next; node != NULL; node = node->rq_next) len += node->rq_buflen; - res = lalloc(len + 1, TRUE); + res = alloc(len + 1); if (res == NULL) return NULL; p = res; diff --git a/src/diff.c b/src/diff.c index 3c72e12bf..7210ce268 100644 --- a/src/diff.c +++ b/src/diff.c @@ -710,7 +710,7 @@ diff_write_buffer(buf_T *buf, diffin_T *din) // xdiff requires one big block of memory with all the text. for (lnum = 1; lnum <= buf->b_ml.ml_line_count; ++lnum) len += (long)STRLEN(ml_get_buf(buf, lnum, FALSE)) + 1; - ptr = lalloc(len, TRUE); + ptr = alloc(len); if (ptr == NULL) { // Allocating memory failed. This can happen, because we try to read diff --git a/src/edit.c b/src/edit.c index 6e2fdb844..6e4b4743c 100644 --- a/src/edit.c +++ b/src/edit.c @@ -3859,7 +3859,7 @@ replace_push( if (replace_stack_len <= replace_stack_nr) { replace_stack_len += 50; - p = lalloc(sizeof(char_u) * replace_stack_len, TRUE); + p = alloc(sizeof(char_u) * replace_stack_len); if (p == NULL) /* out of memory */ { replace_stack_len -= 50; diff --git a/src/eval.c b/src/eval.c index 4796a25bb..1d5d0f11a 100644 --- a/src/eval.c +++ b/src/eval.c @@ -491,7 +491,7 @@ var_redir_start(char_u *name, int append) if (redir_varname == NULL) return FAIL; - redir_lval = (lval_T *)alloc_clear((unsigned)sizeof(lval_T)); + redir_lval = (lval_T *)alloc_clear(sizeof(lval_T)); if (redir_lval == NULL) { var_redir_stop(); @@ -7288,7 +7288,7 @@ handle_subscript( typval_T * alloc_tv(void) { - return (typval_T *)alloc_clear((unsigned)sizeof(typval_T)); + return (typval_T *)alloc_clear(sizeof(typval_T)); } /* diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 7420d6752..3d967580b 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -397,7 +397,7 @@ ex_sort(exarg_T *eap) sortbuf1 = NULL; sortbuf2 = NULL; regmatch.regprog = NULL; - nrs = (sorti_T *)lalloc((long_u)(count * sizeof(sorti_T)), TRUE); + nrs = (sorti_T *)alloc(count * sizeof(sorti_T)); if (nrs == NULL) goto sortend; @@ -793,8 +793,7 @@ ex_retab(exarg_T *eap) /* len is actual number of white characters used */ len = num_spaces + num_tabs; old_len = (long)STRLEN(ptr); - new_line = lalloc(old_len - col + start_col + len + 1, - TRUE); + new_line = alloc(old_len - col + start_col + len + 1); if (new_line == NULL) break; if (start_col > 0) @@ -1745,7 +1744,7 @@ make_filter_cmd( len += (long_u)STRLEN(itmp) + 9; /* " { < " + " } " */ if (otmp != NULL) len += (long_u)STRLEN(otmp) + (long_u)STRLEN(p_srr) + 2; /* " " */ - buf = lalloc(len, TRUE); + buf = alloc(len); if (buf == NULL) return NULL; @@ -2536,7 +2535,7 @@ viminfo_readstring( if (virp->vir_line[off] == Ctrl_V && vim_isdigit(virp->vir_line[off + 1])) { len = atol((char *)virp->vir_line + off + 1); - retval = lalloc(len, TRUE); + retval = alloc(len); if (retval == NULL) { /* Line too long? File messed up? Skip next line. */ diff --git a/src/ex_getln.c b/src/ex_getln.c index 00193fee8..530efce57 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4166,7 +4166,7 @@ ExpandOne( len = 0; for (i = 0; i < xp->xp_numfiles; ++i) len += (long_u)STRLEN(xp->xp_files[i]) + 1; - ss = lalloc(len, TRUE); + ss = alloc(len); if (ss != NULL) { *ss = NUL; @@ -5914,8 +5914,8 @@ init_history(void) { if (newlen) { - temp = (histentry_T *)lalloc( - (long_u)(newlen * sizeof(histentry_T)), TRUE); + temp = (histentry_T *)alloc( + (long_u)(newlen * sizeof(histentry_T))); if (temp == NULL) /* out of memory! */ { if (type == 0) /* first one: just keep the old length */ @@ -6688,7 +6688,7 @@ read_viminfo_history(vir_T *virp, int writing) { /* Need to re-allocate to append the separator byte. */ len = STRLEN(val); - p = lalloc(len + 2, TRUE); + p = alloc(len + 2); if (p != NULL) { if (type == HIST_SEARCH) @@ -6774,7 +6774,7 @@ handle_viminfo_history( { /* Need to re-allocate to append the separator byte. */ len = vp[3].bv_len; - p = lalloc(len + 2, TRUE); + p = alloc(len + 2); } else len = 0; /* for picky compilers */ diff --git a/src/fileio.c b/src/fileio.c index 4182d563f..96207ab9c 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -89,7 +89,7 @@ struct bw_info int bw_restlen; /* nr of bytes in bw_rest[] */ int bw_first; /* first write call */ char_u *bw_conv_buf; /* buffer for writing converted chars */ - int bw_conv_buflen; /* size of bw_conv_buf */ + size_t bw_conv_buflen; /* size of bw_conv_buf */ int bw_conv_error; /* set for conversion error */ linenr_T bw_conv_error_lnum; /* first line with error or zero */ linenr_T bw_start_lnum; /* line number at start of buffer */ @@ -1189,7 +1189,7 @@ retry: { for ( ; size >= 10; size = (long)((long_u)size >> 1)) { - if ((new_buffer = lalloc((long_u)(size + linerest + 1), + if ((new_buffer = lalloc(size + linerest + 1, FALSE)) != NULL) break; } @@ -4168,8 +4168,7 @@ buf_write( write_info.bw_conv_buflen = bufsize * 2; else /* FIO_UCS4 */ write_info.bw_conv_buflen = bufsize * 4; - write_info.bw_conv_buf - = lalloc((long_u)write_info.bw_conv_buflen, TRUE); + write_info.bw_conv_buf = alloc(write_info.bw_conv_buflen); if (write_info.bw_conv_buf == NULL) end = 0; } @@ -4180,8 +4179,7 @@ buf_write( { /* Convert UTF-8 -> UCS-2 and UCS-2 -> DBCS. Worst-case * 4: */ write_info.bw_conv_buflen = bufsize * 4; - write_info.bw_conv_buf - = lalloc((long_u)write_info.bw_conv_buflen, TRUE); + write_info.bw_conv_buf = alloc(write_info.bw_conv_buflen); if (write_info.bw_conv_buf == NULL) end = 0; } @@ -4191,8 +4189,7 @@ buf_write( if (converted && wb_flags == 0 && (wb_flags = get_mac_fio_flags(fenc)) != 0) { write_info.bw_conv_buflen = bufsize * 3; - write_info.bw_conv_buf - = lalloc((long_u)write_info.bw_conv_buflen, TRUE); + write_info.bw_conv_buf = alloc(write_info.bw_conv_buflen); if (write_info.bw_conv_buf == NULL) end = 0; } @@ -4212,8 +4209,7 @@ buf_write( { /* We're going to use iconv(), allocate a buffer to convert in. */ write_info.bw_conv_buflen = bufsize * ICONV_MULT; - write_info.bw_conv_buf - = lalloc((long_u)write_info.bw_conv_buflen, TRUE); + write_info.bw_conv_buf = alloc(write_info.bw_conv_buflen); if (write_info.bw_conv_buf == NULL) end = 0; write_info.bw_first = TRUE; diff --git a/src/getchar.c b/src/getchar.c index 0ebe715cd..9eacdc9a9 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -156,7 +156,7 @@ get_buffcont( for (bp = buffer->bh_first.b_next; bp != NULL; bp = bp->b_next) count += (long_u)STRLEN(bp->b_str); - if ((count || dozero) && (p = lalloc(count + 1, TRUE)) != NULL) + if ((count || dozero) && (p = alloc(count + 1)) != NULL) { p2 = p; for (bp = buffer->bh_first.b_next; bp != NULL; bp = bp->b_next) @@ -258,8 +258,7 @@ add_buff( len = MINIMAL_SIZE; else len = slen; - p = (buffblock_T *)lalloc((long_u)(sizeof(buffblock_T) + len), - TRUE); + p = (buffblock_T *)alloc(sizeof(buffblock_T) + len); if (p == NULL) return; /* no space, just forget it */ buf->bh_space = (int)(len - slen); diff --git a/src/gui_mac.c b/src/gui_mac.c index c177ee650..41fb01ec3 100644 --- a/src/gui_mac.c +++ b/src/gui_mac.c @@ -4476,7 +4476,7 @@ clip_mch_request_selection(VimClipboard *cbd) /* In CARBON we don't need a Handle, a pointer is good */ textOfClip = NewHandle(scrapSize); - /* tempclip = lalloc(scrapSize+1, TRUE); */ + /* tempclip = alloc(scrapSize+1); */ HLock(textOfClip); error = GetScrapFlavorData(scrap, flavor ? VIMSCRAPFLAVOR : SCRAPTEXTFLAVOR, @@ -4488,7 +4488,7 @@ clip_mch_request_selection(VimClipboard *cbd) else type = MAUTO; - tempclip = lalloc(scrapSize + 1, TRUE); + tempclip = alloc(scrapSize + 1); mch_memmove(tempclip, *textOfClip + flavor, scrapSize); tempclip[scrapSize] = 0; diff --git a/src/gui_w32.c b/src/gui_w32.c index bf2738606..fd46b6685 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -6803,12 +6803,12 @@ gui_mch_dialog( dfltbutton = -1; /* Allocate array to hold the width of each button */ - buttonWidths = (int *)lalloc(numButtons * sizeof(int), TRUE); + buttonWidths = (int *)alloc(numButtons * sizeof(int)); if (buttonWidths == NULL) return -1; /* Allocate array to hold the X position of each button */ - buttonPositions = (int *)lalloc(numButtons * sizeof(int), TRUE); + buttonPositions = (int *)alloc(numButtons * sizeof(int)); if (buttonPositions == NULL) return -1; diff --git a/src/gui_x11.c b/src/gui_x11.c index 6ff164417..01881380b 100644 --- a/src/gui_x11.c +++ b/src/gui_x11.c @@ -1167,7 +1167,7 @@ gui_mch_prepare(int *argc, char **argv) * Move all the entries in argv which are relevant to X into gui_argv. */ gui_argc = 0; - gui_argv = (char **)lalloc((long_u)(*argc * sizeof(char *)), FALSE); + gui_argv = (char **)lalloc(*argc * sizeof(char *), FALSE); if (gui_argv == NULL) return; gui_argv[gui_argc++] = argv[0]; diff --git a/src/insexpand.c b/src/insexpand.c index 4a807f48c..387f0666d 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -611,7 +611,7 @@ ins_compl_add( // Allocate a new match structure. // Copy the values to the new match structure. - match = (compl_T *)alloc_clear((unsigned)sizeof(compl_T)); + match = (compl_T *)alloc_clear(sizeof(compl_T)); if (match == NULL) return FAIL; match->cp_number = -1; @@ -1071,8 +1071,7 @@ ins_compl_show_pum(void) if (compl_match_arraysize == 0) return; compl_match_array = (pumitem_T *)alloc_clear( - (unsigned)(sizeof(pumitem_T) - * compl_match_arraysize)); + sizeof(pumitem_T) * compl_match_arraysize); if (compl_match_array != NULL) { // If the current match is the original text don't find the first diff --git a/src/menu.c b/src/menu.c index 1ff45b98d..f32fe4992 100644 --- a/src/menu.c +++ b/src/menu.c @@ -583,7 +583,7 @@ add_menu_path( } /* Not already there, so lets add it */ - menu = (vimmenu_T *)alloc_clear((unsigned)sizeof(vimmenu_T)); + menu = (vimmenu_T *)alloc_clear(sizeof(vimmenu_T)); if (menu == NULL) goto erret; diff --git a/src/netbeans.c b/src/netbeans.c index f1ba01a08..2d55b8006 100644 --- a/src/netbeans.c +++ b/src/netbeans.c @@ -863,7 +863,7 @@ nb_unquote(char_u *p, char_u **endp) int done = 0; /* result is never longer than input */ - result = (char *)alloc_clear((unsigned)STRLEN(p) + 1); + result = (char *)alloc_clear(STRLEN(p) + 1); if (result == NULL) return NULL; @@ -3210,7 +3210,8 @@ addsigntype( if (globalsignmaplen == 0) /* first allocation */ { globalsignmaplen = 20; - globalsignmap = (char **)alloc_clear(globalsignmaplen*sizeof(char *)); + globalsignmap = (char **)alloc_clear( + globalsignmaplen * sizeof(char *)); } else /* grow it */ { @@ -1160,7 +1160,7 @@ stuff_yank(int regname, char_u *p) if (y_append && y_current->y_array != NULL) { pp = &(y_current->y_array[y_current->y_size - 1]); - lp = lalloc((long_u)(STRLEN(*pp) + STRLEN(p) + 1), TRUE); + lp = alloc(STRLEN(*pp) + STRLEN(p) + 1); if (lp == NULL) { vim_free(p); @@ -3057,8 +3057,8 @@ op_yank(oparg_T *oap, int deleting, int mess) y_current->y_size = yanklines; y_current->y_type = yanktype; /* set the yank register type */ y_current->y_width = 0; - y_current->y_array = (char_u **)lalloc_clear((long_u)(sizeof(char_u *) * - yanklines), TRUE); + y_current->y_array = (char_u **)lalloc_clear(sizeof(char_u *) * yanklines, + TRUE); if (y_current->y_array == NULL) { y_current = curr; @@ -3171,8 +3171,8 @@ op_yank(oparg_T *oap, int deleting, int mess) if (curr != y_current) /* append the new block to the old block */ { - new_ptr = (char_u **)lalloc((long_u)(sizeof(char_u *) * - (curr->y_size + y_current->y_size)), TRUE); + new_ptr = (char_u **)alloc(sizeof(char_u *) * + (curr->y_size + y_current->y_size)); if (new_ptr == NULL) goto fail; for (j = 0; j < curr->y_size; ++j) @@ -3190,8 +3190,8 @@ op_yank(oparg_T *oap, int deleting, int mess) * the new block, unless being Vi compatible. */ if (curr->y_type == MCHAR && vim_strchr(p_cpo, CPO_REGAPPEND) == NULL) { - pnew = lalloc((long_u)(STRLEN(curr->y_array[curr->y_size - 1]) - + STRLEN(y_current->y_array[0]) + 1), TRUE); + pnew = alloc(STRLEN(curr->y_array[curr->y_size - 1]) + + STRLEN(y_current->y_array[0]) + 1); if (pnew == NULL) { y_idx = y_current->y_size - 1; @@ -4453,13 +4453,13 @@ do_join( /* Allocate an array to store the number of spaces inserted before each * line. We will use it to pre-compute the length of the new line and the * proper placement of each original line in the new one. */ - spaces = lalloc_clear((long_u)count, TRUE); + spaces = lalloc_clear(count, TRUE); if (spaces == NULL) return FAIL; #if defined(FEAT_COMMENTS) || defined(PROTO) if (remove_comments) { - comments = (int *)lalloc_clear((long_u)count * sizeof(int), TRUE); + comments = (int *)lalloc_clear(count * sizeof(int), TRUE); if (comments == NULL) { vim_free(spaces); @@ -4571,8 +4571,8 @@ do_join( // Allocate an array to copy the text properties of joined lines into. // And another array to store the number of properties in each line. prop_lines = (textprop_T **)alloc_clear( - (int)(count - 1) * sizeof(textprop_T *)); - prop_lengths = (int *)alloc_clear((int)(count - 1) * sizeof(int)); + (count - 1) * sizeof(textprop_T *)); + prop_lengths = (int *)alloc_clear((count - 1) * sizeof(int)); if (prop_lengths == NULL) VIM_CLEAR(prop_lines); } @@ -6600,7 +6600,7 @@ clip_convert_selection(char_u **str, long_u *len, VimClipboard *cbd) if (y_ptr->y_type == MCHAR && *len >= eolsize) *len -= eolsize; - p = *str = lalloc(*len + 1, TRUE); /* add one to avoid zero */ + p = *str = alloc(*len + 1); // add one to avoid zero if (p == NULL) return -1; lnum = 0; @@ -6818,7 +6818,7 @@ get_reg_contents(int regname, int flags) ++len; } - retval = lalloc(len + 1, TRUE); + retval = alloc(len + 1); /* * Copy the lines of the yank register into the string. diff --git a/src/os_amiga.c b/src/os_amiga.c index ec392cd7f..d99c19886 100644 --- a/src/os_amiga.c +++ b/src/os_amiga.c @@ -1448,7 +1448,7 @@ mch_expandpath( #ifdef __amigaos4__ Anchor = AllocDosObject(DOS_ANCHORPATH, AnchorTags); #else - Anchor = (struct AnchorPath *)alloc_clear((unsigned)ANCHOR_SIZE); + Anchor = (struct AnchorPath *)alloc_clear(ANCHOR_SIZE); #endif if (Anchor == NULL) return 0; diff --git a/src/os_mswin.c b/src/os_mswin.c index 67989fe28..6f3e708db 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -890,7 +890,7 @@ mch_libcall( else if (retval_str != NULL && (len = check_str_len(retval_str)) > 0) { - *string_result = lalloc((long_u)len, TRUE); + *string_result = alloc(len); if (*string_result != NULL) mch_memmove(*string_result, retval_str, len); } diff --git a/src/os_qnx.c b/src/os_qnx.c index 8091599ec..79b7ec0f6 100644 --- a/src/os_qnx.c +++ b/src/os_qnx.c @@ -120,7 +120,7 @@ clip_mch_set_selection(VimClipboard *cbd) type = clip_convert_selection(&str, &len, cbd); if (type >= 0) { - text_clip = lalloc(len + 1, TRUE); /* Normal text */ + text_clip = alloc(len + 1); // Normal text if (text_clip && vim_clip) { diff --git a/src/os_unix.c b/src/os_unix.c index 0ec48a112..803f9441c 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4459,9 +4459,9 @@ mch_call_shell_system( else x = system((char *)cmd); # else - newcmd = lalloc(STRLEN(p_sh) + newcmd = alloc(STRLEN(p_sh) + (extra_shell_arg == NULL ? 0 : STRLEN(extra_shell_arg)) - + STRLEN(p_shcf) + STRLEN(cmd) + 4, TRUE); + + STRLEN(p_shcf) + STRLEN(cmd) + 4); if (newcmd == NULL) x = 0; else diff --git a/src/os_win32.c b/src/os_win32.c index d2907102e..5bec2a219 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -3394,7 +3394,7 @@ mch_get_acl(char_u *fname) struct my_acl *p = NULL; DWORD err; - p = (struct my_acl *)alloc_clear((unsigned)sizeof(struct my_acl)); + p = (struct my_acl *)alloc_clear(sizeof(struct my_acl)); if (p != NULL) { WCHAR *wn; @@ -4533,7 +4533,7 @@ mch_call_shell_terminal( cmdlen = STRLEN(p_sh) + 1; else cmdlen = STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10; - newcmd = lalloc(cmdlen, TRUE); + newcmd = alloc(cmdlen); if (newcmd == NULL) return 255; if (cmd == NULL) @@ -4772,7 +4772,7 @@ mch_call_shell( { /* make "cmd.exe /c arguments" */ cmdlen = STRLEN(cmd_shell) + STRLEN(subcmd) + 5; - newcmd = lalloc(cmdlen, TRUE); + newcmd = alloc(cmdlen); if (newcmd != NULL) vim_snprintf((char *)newcmd, cmdlen, "%s /c %s", cmd_shell, subcmd); @@ -4827,7 +4827,7 @@ mch_call_shell( #endif STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10; - newcmd = lalloc(cmdlen, TRUE); + newcmd = alloc(cmdlen); if (newcmd != NULL) { #if defined(FEAT_GUI_MSWIN) diff --git a/src/popupmnu.c b/src/popupmnu.c index 0b002f53e..e5811d31b 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -1071,7 +1071,7 @@ split_message(char_u *mesg, pumitem_T **array) * position. */ if (height > max_height) height = max_height; - *array = (pumitem_T *)alloc_clear((unsigned)sizeof(pumitem_T) * height); + *array = (pumitem_T *)alloc_clear(sizeof(pumitem_T) * height); if (*array == NULL) goto failed; @@ -1165,7 +1165,7 @@ ui_post_balloon(char_u *mesg, list_T *list) balloon_arraysize = list->lv_len; balloon_array = (pumitem_T *)alloc_clear( - (unsigned)sizeof(pumitem_T) * list->lv_len); + sizeof(pumitem_T) * list->lv_len); if (balloon_array == NULL) return; for (idx = 0, li = list->lv_first; li != NULL; li = li->li_next, ++idx) @@ -1271,7 +1271,7 @@ pum_show_popupmenu(vimmenu_T *menu) return; } - array = (pumitem_T *)alloc_clear((unsigned)sizeof(pumitem_T) * pum_size); + array = (pumitem_T *)alloc_clear(sizeof(pumitem_T) * pum_size); if (array == NULL) return; diff --git a/src/quickfix.c b/src/quickfix.c index 46eae2dd2..69ffc9c28 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -540,7 +540,7 @@ parse_efm_option(char_u *efm) while (efm[0] != NUL) { // Allocate a new eformat structure and put it at the end of the list - fmt_ptr = (efm_T *)alloc_clear((unsigned)sizeof(efm_T)); + fmt_ptr = (efm_T *)alloc_clear(sizeof(efm_T)); if (fmt_ptr == NULL) goto parse_efm_error; if (fmt_first == NULL) // first one @@ -2141,7 +2141,7 @@ qf_alloc_stack(qfltype_T qfltype) { qf_info_T *qi; - qi = (qf_info_T *)alloc_clear((unsigned)sizeof(qf_info_T)); + qi = (qf_info_T *)alloc_clear(sizeof(qf_info_T)); if (qi != NULL) { qi->qf_refcount++; diff --git a/src/regexp.c b/src/regexp.c index 3697cd983..b09038992 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -1319,7 +1319,7 @@ bt_regcomp(char_u *expr, int re_flags) return NULL; /* Allocate space. */ - r = (bt_regprog_T *)lalloc(sizeof(bt_regprog_T) + regsize, TRUE); + r = (bt_regprog_T *)alloc(sizeof(bt_regprog_T) + regsize); if (r == NULL) return NULL; r->re_in_use = FALSE; @@ -3932,7 +3932,7 @@ make_extmatch(void) { reg_extmatch_T *em; - em = (reg_extmatch_T *)alloc_clear((unsigned)sizeof(reg_extmatch_T)); + em = (reg_extmatch_T *)alloc_clear(sizeof(reg_extmatch_T)); if (em != NULL) em->refcnt = 1; return em; @@ -7830,7 +7830,7 @@ reg_submatch(int no) if (retval == NULL) { - retval = lalloc((long_u)len, TRUE); + retval = alloc(len); if (retval == NULL) return NULL; } diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index a214b4a3f..f81c05d76 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -300,7 +300,7 @@ nfa_regcomp_start( /* Size for postfix representation of expr. */ postfix_size = sizeof(int) * nstate_max; - post_start = (int *)lalloc(postfix_size, TRUE); + post_start = (int *)alloc(postfix_size); if (post_start == NULL) return FAIL; post_ptr = post_start; @@ -516,7 +516,7 @@ realloc_post_list(void) // For weird patterns the number of states can be very high. Increasing by // 50% seems a reasonable compromise between memory use and speed. new_max = nstate_max * 3 / 2; - new_start = (int *)lalloc(new_max * sizeof(int), TRUE); + new_start = (int *)alloc(new_max * sizeof(int)); if (new_start == NULL) return FAIL; mch_memmove(new_start, post_start, nstate_max * sizeof(int)); @@ -3214,7 +3214,7 @@ post2nfa(int *postfix, int *end, int nfa_calc_size) if (nfa_calc_size == FALSE) { // Allocate space for the stack. Max states on the stack: "nstate'. - stack = (Frag_T *)lalloc((nstate + 1) * sizeof(Frag_T), TRUE); + stack = (Frag_T *)alloc((nstate + 1) * sizeof(Frag_T)); if (stack == NULL) return NULL; stackp = stack; @@ -5184,7 +5184,7 @@ recursive_regmatch( if (*listids == NULL || *listids_len < prog->nstate) { vim_free(*listids); - *listids = (int *)lalloc(sizeof(int) * prog->nstate, TRUE); + *listids = (int *)alloc(sizeof(int) * prog->nstate); if (*listids == NULL) { emsg(_("E878: (NFA) Could not allocate memory for branch traversal!")); @@ -5567,9 +5567,9 @@ nfa_regmatch( /* Allocate memory for the lists of nodes. */ size = (prog->nstate + 1) * sizeof(nfa_thread_T); - list[0].t = (nfa_thread_T *)lalloc(size, TRUE); + list[0].t = (nfa_thread_T *)alloc(size); list[0].len = prog->nstate + 1; - list[1].t = (nfa_thread_T *)lalloc(size, TRUE); + list[1].t = (nfa_thread_T *)alloc(size); list[1].len = prog->nstate + 1; if (list[0].t == NULL || list[1].t == NULL) goto theend; @@ -7276,7 +7276,7 @@ nfa_regcomp(char_u *expr, int re_flags) /* allocate the regprog with space for the compiled regexp */ prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * (nstate - 1); - prog = (nfa_regprog_T *)lalloc(prog_size, TRUE); + prog = (nfa_regprog_T *)alloc(prog_size); if (prog == NULL) goto fail; state_ptr = prog->state; diff --git a/src/screen.c b/src/screen.c index cb10f6ee9..469177505 100644 --- a/src/screen.c +++ b/src/screen.c @@ -8782,26 +8782,25 @@ retry: if (aucmd_win != NULL) win_free_lsize(aucmd_win); - new_ScreenLines = (schar_T *)lalloc((long_u)( - (Rows + 1) * Columns * sizeof(schar_T)), FALSE); + new_ScreenLines = (schar_T *)lalloc( + (Rows + 1) * Columns * sizeof(schar_T), FALSE); vim_memset(new_ScreenLinesC, 0, sizeof(u8char_T *) * MAX_MCO); if (enc_utf8) { - new_ScreenLinesUC = (u8char_T *)lalloc((long_u)( - (Rows + 1) * Columns * sizeof(u8char_T)), FALSE); + new_ScreenLinesUC = (u8char_T *)lalloc( + (Rows + 1) * Columns * sizeof(u8char_T), FALSE); for (i = 0; i < p_mco; ++i) - new_ScreenLinesC[i] = (u8char_T *)lalloc_clear((long_u)( - (Rows + 1) * Columns * sizeof(u8char_T)), FALSE); + new_ScreenLinesC[i] = (u8char_T *)lalloc_clear( + (Rows + 1) * Columns * sizeof(u8char_T), FALSE); } if (enc_dbcs == DBCS_JPNU) - new_ScreenLines2 = (schar_T *)lalloc((long_u)( - (Rows + 1) * Columns * sizeof(schar_T)), FALSE); - new_ScreenAttrs = (sattr_T *)lalloc((long_u)( - (Rows + 1) * Columns * sizeof(sattr_T)), FALSE); - new_LineOffset = (unsigned *)lalloc((long_u)( - Rows * sizeof(unsigned)), FALSE); - new_LineWraps = (char_u *)lalloc((long_u)(Rows * sizeof(char_u)), FALSE); - new_TabPageIdxs = (short *)lalloc((long_u)(Columns * sizeof(short)), FALSE); + new_ScreenLines2 = (schar_T *)lalloc( + (Rows + 1) * Columns * sizeof(schar_T), FALSE); + new_ScreenAttrs = (sattr_T *)lalloc( + (Rows + 1) * Columns * sizeof(sattr_T), FALSE); + new_LineOffset = (unsigned *)lalloc(Rows * sizeof(unsigned), FALSE); + new_LineWraps = (char_u *)lalloc(Rows * sizeof(char_u), FALSE); + new_TabPageIdxs = (short *)lalloc(Columns * sizeof(short), FALSE); FOR_ALL_TAB_WINDOWS(tp, wp) { @@ -10741,7 +10740,7 @@ redraw_win_toolbar(win_T *wp) for (menu = wp->w_winbar->children; menu != NULL; menu = menu->next) ++item_count; wp->w_winbar_items = (winbar_item_T *)alloc_clear( - (unsigned)sizeof(winbar_item_T) * (item_count + 1)); + sizeof(winbar_item_T) * (item_count + 1)); /* TODO: use fewer spaces if there is not enough room */ for (menu = wp->w_winbar->children; diff --git a/src/search.c b/src/search.c index f7b3dda31..bbe370356 100644 --- a/src/search.c +++ b/src/search.c @@ -5137,8 +5137,8 @@ find_pattern_in_path( goto fpip_end; def_regmatch.rm_ic = FALSE; /* don't ignore case in define pat. */ } - files = (SearchedFile *)lalloc_clear((long_u) - (max_path_depth * sizeof(SearchedFile)), TRUE); + files = (SearchedFile *)lalloc_clear( + max_path_depth * sizeof(SearchedFile), TRUE); if (files == NULL) goto fpip_end; old_files = max_path_depth; @@ -5298,8 +5298,8 @@ find_pattern_in_path( /* Push the new file onto the file stack */ if (depth + 1 == old_files) { - bigger = (SearchedFile *)lalloc((long_u)( - max_path_depth * 2 * sizeof(SearchedFile)), TRUE); + bigger = (SearchedFile *)alloc( + max_path_depth * 2 * sizeof(SearchedFile)); if (bigger != NULL) { for (i = 0; i <= depth; i++) diff --git a/src/sign.c b/src/sign.c index cc5190107..32e6bad18 100644 --- a/src/sign.c +++ b/src/sign.c @@ -202,8 +202,8 @@ insert_sign( { signlist_T *newsign; - newsign = (signlist_T *)lalloc_id((long_u)sizeof(signlist_T), FALSE, - aid_insert_sign); + newsign = (signlist_T *)lalloc_id(sizeof(signlist_T), FALSE, + aid_insert_sign); if (newsign != NULL) { newsign->id = id; @@ -1057,7 +1057,7 @@ sign_jump(int sign_id, char_u *sign_group, buf_T *buf) emsg(_("E934: Cannot jump to a buffer that does not have a name")); return -1; } - cmd = alloc((unsigned)STRLEN(buf->b_fname) + 25); + cmd = alloc(STRLEN(buf->b_fname) + 25); if (cmd == NULL) return -1; sprintf((char *)cmd, "e +%ld %s", (long)lnum, buf->b_fname); diff --git a/src/spell.c b/src/spell.c index fa5be8be1..1e14fabff 100644 --- a/src/spell.c +++ b/src/spell.c @@ -7820,8 +7820,7 @@ spell_edit_score( /* We use "cnt" as an array: CNT(badword_idx, goodword_idx). */ #define CNT(a, b) cnt[(a) + (b) * (badlen + 1)] - cnt = (int *)lalloc((long_u)(sizeof(int) * (badlen + 1) * (goodlen + 1)), - TRUE); + cnt = (int *)alloc(sizeof(int) * (badlen + 1) * (goodlen + 1)); if (cnt == NULL) return 0; /* out of memory */ diff --git a/src/spellfile.c b/src/spellfile.c index 06cf1bcab..0a16514a4 100644 --- a/src/spellfile.c +++ b/src/spellfile.c @@ -892,8 +892,7 @@ read_prefcond_section(FILE *fd, slang_T *lp) if (cnt <= 0) return SP_FORMERROR; - lp->sl_prefprog = (regprog_T **)alloc_clear( - (unsigned)sizeof(regprog_T *) * cnt); + lp->sl_prefprog = (regprog_T **)alloc_clear(sizeof(regprog_T *) * cnt); if (lp->sl_prefprog == NULL) return SP_OTHERERROR; lp->sl_prefixcnt = cnt; @@ -1580,13 +1579,13 @@ spell_read_tree( if (len > 0) { /* Allocate the byte array. */ - bp = lalloc((long_u)len, TRUE); + bp = alloc(len); if (bp == NULL) return SP_OTHERERROR; *bytsp = bp; /* Allocate the index array. */ - ip = (idx_T *)lalloc_clear((long_u)(len * sizeof(int)), TRUE); + ip = (idx_T *)lalloc_clear(len * sizeof(int), TRUE); if (ip == NULL) return SP_OTHERERROR; *idxsp = ip; @@ -4272,8 +4271,7 @@ getroom( bl = NULL; else /* Allocate a block of memory. It is not freed until much later. */ - bl = (sblock_T *)alloc_clear( - (unsigned)(sizeof(sblock_T) + SBLOCKSIZE)); + bl = (sblock_T *)alloc_clear(sizeof(sblock_T) + SBLOCKSIZE); if (bl == NULL) { if (!spin->si_did_emsg) diff --git a/src/syntax.c b/src/syntax.c index 27a64c226..e711198f7 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -1215,7 +1215,7 @@ syn_stack_alloc(void) len = syn_block->b_sst_len - syn_block->b_sst_freecount + 2; } - sstp = (synstate_T *)alloc_clear((unsigned)(len * sizeof(synstate_T))); + sstp = (synstate_T *)alloc_clear(len * sizeof(synstate_T)); if (sstp == NULL) /* out of memory! */ return; @@ -5216,7 +5216,7 @@ syn_cmd_region( } ppp->pp_next = pat_ptrs[item]; pat_ptrs[item] = ppp; - ppp->pp_synp = (synpat_T *)alloc_clear((unsigned)sizeof(synpat_T)); + ppp->pp_synp = (synpat_T *)alloc_clear(sizeof(synpat_T)); if (ppp->pp_synp == NULL) { rest = NULL; @@ -2789,8 +2789,7 @@ findtag_end: match_count = 0; if (match_count > 0) - matches = (char_u **)lalloc((long_u)(match_count * sizeof(char_u *)), - TRUE); + matches = (char_u **)alloc(match_count * sizeof(char_u *)); else matches = NULL; match_count = 0; diff --git a/src/terminal.c b/src/terminal.c index caa4c8573..1ceac3ada 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -3925,7 +3925,7 @@ static VTermParserCallbacks parser_fallbacks = { static void * vterm_malloc(size_t size, void *data UNUSED) { - return alloc_clear((unsigned) size); + return alloc_clear(size); } static void diff --git a/src/textprop.c b/src/textprop.c index 66ad69445..e993afce8 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -678,7 +678,7 @@ prop_type_set(typval_T *argvars, int add) semsg(_("E969: Property type %s already defined"), name); return; } - prop = (proptype_T *)alloc_clear((int)(sizeof(proptype_T) + STRLEN(name))); + prop = (proptype_T *)alloc_clear(sizeof(proptype_T) + STRLEN(name)); if (prop == NULL) return; STRCPY(prop->pt_name, name); @@ -1514,7 +1514,7 @@ clip_copy_modeless_selection(int both UNUSED) len *= 2; /* max. 2 bytes per display cell */ else if (enc_utf8) len *= MB_MAXBYTES; - buffer = lalloc((long_u)len, TRUE); + buffer = alloc(len); if (buffer == NULL) /* out of memory */ return; @@ -1897,11 +1897,11 @@ get_input_buf(void) garray_T *gap; /* We use a growarray to store the data pointer and the length. */ - gap = (garray_T *)alloc((unsigned)sizeof(garray_T)); + gap = (garray_T *)alloc(sizeof(garray_T)); if (gap != NULL) { /* Add one to avoid a zero size. */ - gap->ga_data = alloc((unsigned)inbufcount + 1); + gap->ga_data = alloc(inbufcount + 1); if (gap->ga_data != NULL) mch_memmove(gap->ga_data, inbuf, (size_t)inbufcount); gap->ga_len = inbufcount; diff --git a/src/undo.c b/src/undo.c index ed2cd58fe..6547ee642 100644 --- a/src/undo.c +++ b/src/undo.c @@ -124,7 +124,7 @@ static void serialize_visualinfo(bufinfo_T *bi, visualinfo_T *info); static void unserialize_visualinfo(bufinfo_T *bi, visualinfo_T *info); #endif -#define U_ALLOC_LINE(size) lalloc((long_u)(size), FALSE) +#define U_ALLOC_LINE(size) lalloc(size, FALSE) /* used in undo_end() to report number of added and deleted lines */ static long u_newcount, u_oldcount; @@ -2013,8 +2013,7 @@ u_read_undo(char_u *name, char_u *hash, char_u *orig_name) } #ifdef U_DEBUG - uhp_table_used = (int *)alloc_clear( - (unsigned)(sizeof(int) * num_head + 1)); + uhp_table_used = (int *)alloc_clear(sizeof(int) * num_head + 1); # define SET_FLAG(j) ++uhp_table_used[j] #else # define SET_FLAG(j) diff --git a/src/userfunc.c b/src/userfunc.c index dcf803401..0c898efe3 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -292,10 +292,10 @@ get_lambda_tv(char_u **arg, typval_T *rettv, int evaluate) sprintf((char*)name, "<lambda>%d", ++lambda_no); - fp = (ufunc_T *)alloc_clear((unsigned)(sizeof(ufunc_T) + STRLEN(name))); + fp = (ufunc_T *)alloc_clear(sizeof(ufunc_T) + STRLEN(name)); if (fp == NULL) goto errret; - pt = (partial_T *)alloc_clear((unsigned)sizeof(partial_T)); + pt = (partial_T *)alloc_clear(sizeof(partial_T)); if (pt == NULL) goto errret; @@ -2580,7 +2580,7 @@ ex_function(exarg_T *eap) } } - fp = (ufunc_T *)alloc_clear((unsigned)(sizeof(ufunc_T) + STRLEN(name))); + fp = (ufunc_T *)alloc_clear(sizeof(ufunc_T) + STRLEN(name)); if (fp == NULL) goto erret; @@ -2751,14 +2751,13 @@ func_do_profile(ufunc_T *fp) profile_zero(&fp->uf_tm_self); profile_zero(&fp->uf_tm_total); if (fp->uf_tml_count == NULL) - fp->uf_tml_count = (int *)alloc_clear( - (unsigned)(sizeof(int) * len)); + fp->uf_tml_count = (int *)alloc_clear(sizeof(int) * len); if (fp->uf_tml_total == NULL) fp->uf_tml_total = (proftime_T *)alloc_clear( - (unsigned)(sizeof(proftime_T) * len)); + sizeof(proftime_T) * len); if (fp->uf_tml_self == NULL) fp->uf_tml_self = (proftime_T *)alloc_clear( - (unsigned)(sizeof(proftime_T) * len)); + sizeof(proftime_T) * len); fp->uf_tml_idx = -1; if (fp->uf_tml_count == NULL || fp->uf_tml_total == NULL || fp->uf_tml_self == NULL) diff --git a/src/version.c b/src/version.c index a66b7a560..3653b9b61 100644 --- a/src/version.c +++ b/src/version.c @@ -768,6 +768,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1386, +/**/ 1385, /**/ 1384, diff --git a/src/winclip.c b/src/winclip.c index feef18d3c..f6f24d103 100644 --- a/src/winclip.c +++ b/src/winclip.c @@ -244,7 +244,7 @@ crnl_to_nl(const char_u *str, int *size) char_u *retp; /* Avoid allocating zero bytes, it generates an error message. */ - ret = lalloc((long_u)(str_len == 0 ? 1 : str_len), TRUE); + ret = alloc(str_len == 0 ? 1 : str_len); if (ret != NULL) { retp = ret; diff --git a/src/window.c b/src/window.c index fd732f22d..6e02caad6 100644 --- a/src/window.c +++ b/src/window.c @@ -1065,7 +1065,7 @@ win_split_ins( if (curfrp->fr_parent == NULL || curfrp->fr_parent->fr_layout != layout) { /* Need to create a new frame in the tree to make a branch. */ - frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T)); + frp = (frame_T *)alloc_clear(sizeof(frame_T)); *frp = *curfrp; curfrp->fr_layout = layout; frp->fr_parent = curfrp; @@ -3549,7 +3549,7 @@ 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 = (frame_T *)alloc_clear(sizeof(frame_T)); wp->w_frame = frp; if (frp != NULL) @@ -3584,7 +3584,7 @@ alloc_tabpage(void) # endif - tp = (tabpage_T *)alloc_clear((unsigned)sizeof(tabpage_T)); + tp = (tabpage_T *)alloc_clear(sizeof(tabpage_T)); if (tp == NULL) return NULL; @@ -4597,7 +4597,7 @@ win_alloc(win_T *after UNUSED, int hidden UNUSED) /* * allocate window structure and linesizes arrays */ - new_wp = (win_T *)alloc_clear((unsigned)sizeof(win_T)); + new_wp = (win_T *)alloc_clear(sizeof(win_T)); if (new_wp == NULL) return NULL; @@ -4898,7 +4898,7 @@ frame_remove(frame_T *frp) win_alloc_lines(win_T *wp) { wp->w_lines_valid = 0; - wp->w_lines = (wline_T *)alloc_clear((unsigned)(Rows * sizeof(wline_T))); + wp->w_lines = (wline_T *)alloc_clear(Rows * sizeof(wline_T)); if (wp->w_lines == NULL) return FAIL; return OK; @@ -6280,7 +6280,7 @@ make_snapshot(int idx) static void make_snapshot_rec(frame_T *fr, frame_T **frp) { - *frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T)); + *frp = (frame_T *)alloc_clear(sizeof(frame_T)); if (*frp == NULL) return; (*frp)->fr_layout = fr->fr_layout; |