Problem: Using "int" for alloc() often results in compiler warnings.
Solution: Use "size_t" and remove type casts. Remove alloc_check(), Vim
only works with 32 bit ints anyway.
return FAIL;
}
- ap = (AutoPat *)alloc((unsigned)sizeof(AutoPat));
+ ap = (AutoPat *)alloc(sizeof(AutoPat));
if (ap == NULL)
return FAIL;
ap->pat = vim_strnsave(pat, patlen);
prev_ac = &(ap->cmds);
while ((ac = *prev_ac) != NULL)
prev_ac = &ac->next;
- ac = (AutoCmd *)alloc((unsigned)sizeof(AutoCmd));
+ ac = (AutoCmd *)alloc(sizeof(AutoCmd));
if (ac == NULL)
return FAIL;
ac->cmd = vim_strsave(cmd);
{
name = event_nr2name(apc->event);
s = _("%s Autocommands for \"%s\"");
- sourcing_name = alloc((unsigned)(STRLEN(s)
- + STRLEN(name) + ap->patlen + 1));
+ sourcing_name = alloc(STRLEN(s)
+ + STRLEN(name) + ap->patlen + 1);
if (sourcing_name != NULL)
{
sprintf((char *)sourcing_name, s,
/* Make a copy of "pat" and change "^" to "\(^\|[\/]\)". */
if (*pat == '^')
{
- patc = alloc((unsigned)STRLEN(pat) + 11);
+ patc = alloc(STRLEN(pat) + 11);
if (patc == NULL)
return FAIL;
STRCPY(patc, "\\(^\\|[\\/]\\)");
break;
if (round == 1)
{
- *file = (char_u **)alloc((unsigned)(count * sizeof(char_u *)));
+ *file = (char_u **)alloc(count * sizeof(char_u *));
if (*file == NULL)
{
vim_regfree(regmatch.regprog);
}
}
- newp = alloc_check((unsigned)(linelen + newlen - oldlen));
+ newp = alloc(linelen + newlen - oldlen);
if (newp == NULL)
return;
oldp = ml_get(lnum);
oldlen = (int)STRLEN(oldp);
- newp = alloc_check((unsigned)(oldlen + newlen + 1));
+ newp = alloc(oldlen + newlen + 1);
if (newp == NULL)
return;
if (col > 0)
newp = oldp; // use same allocated memory
else
{ // need to allocate a new line
- newp = alloc((unsigned)(newlen + 1));
+ newp = alloc(newlen + 1);
if (newp == NULL)
return FAIL;
mch_memmove(newp, oldp, (size_t)col);
}
else
{
- item = (jsonq_T *)alloc((unsigned)sizeof(jsonq_T));
+ item = (jsonq_T *)alloc(sizeof(jsonq_T));
if (item == NULL)
clear_tv(&listtv);
else
/* append after the last item that was pushed back */
item = item->jq_next;
- newitem = (jsonq_T *)alloc((unsigned)sizeof(jsonq_T));
+ newitem = (jsonq_T *)alloc(sizeof(jsonq_T));
if (newitem == NULL)
clear_tv(rettv);
else
len += 4; /* illegal byte sequence */
}
}
- res = alloc((unsigned)(len + 1));
+ res = alloc(len + 1);
}
else
- res = alloc((unsigned)(vim_strsize(s) + 1));
+ res = alloc(vim_strsize(s) + 1);
if (res != NULL)
{
*res = NUL;
// Replace K_SNR in function name with "<SNR>".
if (!file && fname[0] == K_SPECIAL)
{
- name = alloc((unsigned)STRLEN(fname) + 3);
+ name = alloc(STRLEN(fname) + 3);
if (name == NULL)
name = fname;
else
{
dictitem_T *di;
- di = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T) + STRLEN(key)));
+ di = (dictitem_T *)alloc(sizeof(dictitem_T) + STRLEN(key));
if (di != NULL)
{
STRCPY(di->di_key, key);
{
dictitem_T *di;
- di = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T)
- + STRLEN(org->di_key)));
+ di = (dictitem_T *)alloc(sizeof(dictitem_T) + STRLEN(org->di_key));
if (di != NULL)
{
STRCPY(di->di_key, org->di_key);
{
diff_T *dnew;
- dnew = (diff_T *)alloc((unsigned)sizeof(diff_T));
+ dnew = (diff_T *)alloc(sizeof(diff_T));
if (dnew != NULL)
{
dnew->df_next = dp;
{
len = STRLEN(tmp_orig) + STRLEN(tmp_new)
+ STRLEN(tmp_diff) + STRLEN(p_srr) + 27;
- cmd = alloc((unsigned)len);
+ cmd = alloc(len);
if (cmd == NULL)
return FAIL;
if (esc_name == NULL)
goto theend;
buflen = STRLEN(tmp_orig) + STRLEN(esc_name) + STRLEN(tmp_new) + 16;
- buf = alloc((unsigned)buflen);
+ buf = alloc(buflen);
if (buf == NULL)
goto theend;
/* Source the keymap file. It will contain a ":loadkeymap" command
* which will call ex_loadkeymap() below. */
buflen = STRLEN(curbuf->b_p_keymap) + STRLEN(p_enc) + 14;
- buf = alloc((unsigned)buflen);
+ buf = alloc(buflen);
if (buf == NULL)
return e_outofmem;
{
curwin->w_cursor.col = (colnr_T)new_cursor_col;
i = (int)curwin->w_virtcol - vcol;
- ptr = alloc((unsigned)(i + 1));
+ ptr = alloc(i + 1);
if (ptr != NULL)
{
new_cursor_col += i;
* Copy the string into allocated memory, handling backslashed
* characters.
*/
- name = alloc((unsigned)(p - *arg + extra));
+ name = alloc(p - *arg + extra);
if (name == NULL)
return FAIL;
rettv->v_type = VAR_STRING;
/*
* Copy the string into allocated memory, handling '' to ' reduction.
*/
- str = alloc((unsigned)((p - *arg) - reduce));
+ str = alloc((p - *arg) - reduce);
if (str == NULL)
return FAIL;
rettv->v_type = VAR_STRING;
temp_result = eval_to_string(expr_start + 1, &nextcmd, FALSE);
if (temp_result != NULL && nextcmd == NULL)
{
- retval = alloc((unsigned)(STRLEN(temp_result) + (expr_start - in_start)
- + (in_end - expr_end) + 1));
+ retval = alloc(STRLEN(temp_result) + (expr_start - in_start)
+ + (in_end - expr_end) + 1);
if (retval != NULL)
{
STRCPY(retval, in_start);
if (!valid_varname(varname))
return;
- v = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T)
- + STRLEN(varname)));
+ v = (dictitem_T *)alloc(sizeof(dictitem_T) + STRLEN(varname));
if (v == NULL)
return;
STRCPY(v->di_key, varname);
}
else
{
- winvarname = alloc((unsigned)STRLEN(varname) + 3);
+ winvarname = alloc(STRLEN(varname) + 3);
if (winvarname != NULL)
{
STRCPY(winvarname, "w:");
char_u *scriptname;
/* Get the script file name: replace '#' with '/', append ".vim". */
- scriptname = alloc((unsigned)(STRLEN(name) + 14));
+ scriptname = alloc(STRLEN(name) + 14);
if (scriptname == NULL)
return FALSE;
STRCPY(scriptname, "autoload/");
}
count = (long)(foldend - foldstart + 1);
txt = NGETTEXT("+-%s%3ld line: ", "+-%s%3ld lines: ", count);
- r = alloc((unsigned)(STRLEN(txt)
- + STRLEN(dashes) /* for %s */
- + 20 /* for %3ld */
- + STRLEN(s))); /* concatenated */
+ r = alloc(STRLEN(txt)
+ + STRLEN(dashes) // for %s
+ + 20 // for %3ld
+ + STRLEN(s)); // concatenated
if (r != NULL)
{
sprintf((char *)r, txt, dashes, count);
if (q > p && !mch_isFullName(buf))
{
/* symlink is relative to directory of argument */
- cpy = alloc((unsigned)(STRLEN(p) + STRLEN(buf) + 1));
+ cpy = alloc(STRLEN(p) + STRLEN(buf) + 1);
if (cpy != NULL)
{
STRCPY(cpy, p);
/* Make two search patterns: start/end (pat2, for in nested pairs) and
* start/middle/end (pat3, for the top pair). */
- pat2 = alloc((unsigned)(STRLEN(spat) + STRLEN(epat) + 17));
- pat3 = alloc((unsigned)(STRLEN(spat) + STRLEN(mpat) + STRLEN(epat) + 25));
+ pat2 = alloc(STRLEN(spat) + STRLEN(epat) + 17);
+ pat3 = alloc(STRLEN(spat) + STRLEN(mpat) + STRLEN(epat) + 25);
if (pat2 == NULL || pat3 == NULL)
goto theend;
sprintf((char *)pat2, "\\m\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat);
{
buf_T *save_curbuf = curbuf;
- bufvarname = alloc((unsigned)STRLEN(varname) + 3);
+ bufvarname = alloc(STRLEN(varname) + 3);
if (bufvarname != NULL)
{
curbuf = buf;
save_curtab = curtab;
goto_tabpage_tp(tp, FALSE, FALSE);
- tabvarname = alloc((unsigned)STRLEN(varname) + 3);
+ tabvarname = alloc(STRLEN(varname) + 3);
if (tabvarname != NULL)
{
STRCPY(tabvarname, "t:");
++i;
end = res + i;
- s = alloc((unsigned)(end - start + 1));
+ s = alloc(end - start + 1);
if (s == NULL)
goto errret;
}
/* Allocate a buffer that can hold the longest line. */
- sortbuf1 = alloc((unsigned)maxlen + 1);
+ sortbuf1 = alloc(maxlen + 1);
if (sortbuf1 == NULL)
goto sortend;
- sortbuf2 = alloc((unsigned)maxlen + 1);
+ sortbuf2 = alloc(maxlen + 1);
if (sortbuf2 == NULL)
goto sortend;
}
len += (int)STRLEN(prevcmd);
}
- if ((t = alloc((unsigned)len)) == NULL)
+ if ((t = alloc(len)) == NULL)
{
vim_free(newcmd);
return;
*/
if (*p_shq != NUL)
{
- newcmd = alloc((unsigned)(STRLEN(prevcmd) + 2 * STRLEN(p_shq) + 1));
+ newcmd = alloc(STRLEN(prevcmd) + 2 * STRLEN(p_shq) + 1);
if (newcmd == NULL)
return;
STRCPY(newcmd, p_shq);
len = (int)STRLEN(command) + 3;
else
len = 30;
- p = alloc((unsigned)len);
+ p = alloc(len);
if (p != NULL)
{
if (command != NULL)
* too many calls to alloc()/free()).
*/
new_start_len = needed_len + 50;
- if ((new_start = alloc_check(new_start_len)) == NULL)
+ if ((new_start = alloc(new_start_len)) == NULL)
goto outofmem;
*new_start = NUL;
new_end = new_start;
if (needed_len > (int)new_start_len)
{
new_start_len = needed_len + 50;
- if ((p1 = alloc_check(new_start_len)) == NULL)
+ if ((p1 = alloc(new_start_len)) == NULL)
{
vim_free(new_start);
goto outofmem;
got_int = TRUE;
break;
}
- s = alloc((unsigned)(p2 - p1 + STRLEN(fname) + 2));
+ s = alloc(p2 - p1 + STRLEN(fname) + 2);
if (s == NULL)
{
got_int = TRUE;
}
else
{
- buf = alloc((unsigned)(STRLEN(eap->arg) + 14));
+ buf = alloc(STRLEN(eap->arg) + 14);
if (buf != NULL)
{
if (eap->forceit)
i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3;
if (eap->nextcmd != NULL)
i += (int)STRLEN(eap->nextcmd);/* add space for next command */
- if ((new_cmdline = alloc((unsigned)i)) == NULL)
+ if ((new_cmdline = alloc(i)) == NULL)
return NULL; /* out of memory! */
/*
void
alist_new(void)
{
- curwin->w_alist = (alist_T *)alloc((unsigned)sizeof(alist_T));
+ curwin->w_alist = (alist_T *)alloc(sizeof(alist_T));
if (curwin->w_alist == NULL)
{
curwin->w_alist = &global_alist;
* expansion. Also, the vimrc file isn't read yet, thus the user
* can't set the options. */
p_su = empty_option;
- old_arg_files = (char_u **)alloc((unsigned)(sizeof(char_u *) * GARGCOUNT));
+ old_arg_files = (char_u **)alloc(sizeof(char_u *) * GARGCOUNT);
if (old_arg_files != NULL)
{
for (i = 0; i < GARGCOUNT; ++i)
}
if (len > 0)
{
- arg = alloc((unsigned)(STRLEN(eap->arg) + len + 1));
+ arg = alloc(STRLEN(eap->arg) + len + 1);
if (arg != NULL)
{
len = 0;
}
/* allocate memory */
- retval = alloc((unsigned)len + 1);
+ retval = alloc(len + 1);
if (retval == NULL)
break;
}
for (p = sname; *p; ++p)
if (*p == '=' || vim_ispathsep(*p))
++len;
- retval = alloc((unsigned)(STRLEN(sname) + len + STRLEN(p_vdir) + 9));
+ retval = alloc(STRLEN(sname) + len + STRLEN(p_vdir) + 9);
if (retval != NULL)
{
STRCPY(retval, p_vdir);
while (*plist != NULL)
plist = &(*plist)->next;
- elem = (struct msglist *)alloc((unsigned)sizeof(struct msglist));
+ elem = (struct msglist *)alloc(sizeof(struct msglist));
if (elem == NULL)
{
suppress_errthrow = TRUE;
}
}
- excp = (except_T *)alloc((unsigned)sizeof(except_T));
+ excp = (except_T *)alloc(sizeof(except_T));
if (excp == NULL)
goto nomem;
{
eslist_T *elem;
- elem = (eslist_T *)alloc((unsigned)sizeof(struct eslist_elem));
+ elem = (eslist_T *)alloc(sizeof(struct eslist_elem));
if (elem == NULL)
emsg(_(e_outofmem));
else
}
}
- ss = alloc((unsigned)len + 1);
+ ss = alloc(len + 1);
if (ss)
vim_strncpy(ss, xp->xp_files[0], (size_t)len);
findex = -1; /* next p_wc gets first one */
{
char_u *p;
- p = alloc((unsigned)(STRLEN(*pp) + 2));
+ p = alloc(STRLEN(*pp) + 2);
if (p != NULL)
{
p[0] = '\\';
if (count == 0)
return OK;
*num_file = count;
- *file = (char_u **)alloc((unsigned)(count * sizeof(char_u *)));
+ *file = (char_u **)alloc(count * sizeof(char_u *));
if (*file == NULL)
{
*file = (char_u **)"";
for (i = 0; dirnames[i] != NULL; ++i)
{
- s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 7));
+ s = alloc(STRLEN(dirnames[i]) + pat_len + 7);
if (s == NULL)
{
ga_clear_strings(&ga);
if (flags & DIP_START) {
for (i = 0; dirnames[i] != NULL; ++i)
{
- s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 22));
+ s = alloc(STRLEN(dirnames[i]) + pat_len + 22);
if (s == NULL)
{
ga_clear_strings(&ga);
if (flags & DIP_OPT) {
for (i = 0; dirnames[i] != NULL; ++i)
{
- s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 20));
+ s = alloc(STRLEN(dirnames[i]) + pat_len + 20);
if (s == NULL)
{
ga_clear_strings(&ga);
pat_len = (int)STRLEN(pat);
ga_init2(&ga, (int)sizeof(char *), 10);
- s = alloc((unsigned)(pat_len + 26));
+ s = alloc(pat_len + 26);
if (s == NULL)
{
ga_clear_strings(&ga);
*/
if (fname == NULL || *fname == NUL)
{
- retval = alloc((unsigned)(MAXPATHL + extlen + 3));
+ retval = alloc(MAXPATHL + extlen + 3);
if (retval == NULL)
return NULL;
if (mch_dirname(retval, MAXPATHL) == FAIL ||
else
{
fnamelen = (int)STRLEN(fname);
- retval = alloc((unsigned)(fnamelen + extlen + 3));
+ retval = alloc(fnamelen + extlen + 3);
if (retval == NULL)
return NULL;
STRCPY(retval, fname);
{
if (!helpmesg)
mesg2 = "";
- tbuf = (char *)alloc((unsigned)(STRLEN(path) + STRLEN(mesg)
- + STRLEN(mesg2) + 2));
+ tbuf = (char *)alloc(STRLEN(path) + STRLEN(mesg)
+ + STRLEN(mesg2) + 2);
sprintf(tbuf, mesg, path);
#ifdef FEAT_EVAL
/* Set warningmsg here, before the unimportant and output-specific
{
char_u *buf;
- buf = alloc((unsigned)MAXPATHL + 2);
+ buf = alloc(MAXPATHL + 2);
if (buf != NULL)
{
if (vim_FullName(tempdir, buf, MAXPATHL, FALSE) == FAIL)
search_ctx = search_ctx_arg;
else
{
- search_ctx = (ff_search_ctx_T*)alloc((unsigned)sizeof(ff_search_ctx_T));
+ search_ctx = (ff_search_ctx_T*)alloc(sizeof(ff_search_ctx_T));
if (search_ctx == NULL)
goto error_return;
vim_memset(search_ctx, 0, sizeof(ff_search_ctx_T));
walker++;
dircount = 1;
- search_ctx->ffsc_stopdirs_v =
- (char_u **)alloc((unsigned)sizeof(char_u *));
+ search_ctx->ffsc_stopdirs_v = (char_u **)alloc(sizeof(char_u *));
if (search_ctx->ffsc_stopdirs_v != NULL)
{
*/
if (path_with_url(dirptrs[0]))
{
- stackp->ffs_filearray = (char_u **)
- alloc((unsigned)sizeof(char *));
+ stackp->ffs_filearray = (char_u **)alloc(sizeof(char *));
if (stackp->ffs_filearray != NULL
&& (stackp->ffs_filearray[0]
= vim_strsave(dirptrs[0])) != NULL)
/*
* if we reach this we didn't find a list and we have to allocate new list
*/
- retptr = (ff_visited_list_hdr_T*)alloc((unsigned)sizeof(*retptr));
+ retptr = (ff_visited_list_hdr_T*)alloc(sizeof(*retptr));
if (retptr == NULL)
return NULL;
/*
* New file/dir. Add it to the list of visited files/dirs.
*/
- vp = (ff_visited_T *)alloc((unsigned)(sizeof(ff_visited_T)
- + STRLEN(ff_expand_buffer)));
+ vp = (ff_visited_T *)alloc(sizeof(ff_visited_T) + STRLEN(ff_expand_buffer));
if (vp != NULL)
{
{
ff_stack_T *new;
- new = (ff_stack_T *)alloc((unsigned)sizeof(ff_stack_T));
+ new = (ff_stack_T *)alloc(sizeof(ff_stack_T));
if (new == NULL)
return NULL;
char_u *paths = NULL;
int glob_flags = 0;
- if ((curdir = alloc((unsigned)MAXPATHL)) == NULL)
+ if ((curdir = alloc(MAXPATHL)) == NULL)
return 0;
mch_dirname(curdir, MAXPATHL);
/* Check if the line ends with an unclosed comment */
(void)skip_comment(line, FALSE, FALSE, &line_is_comment);
#endif
- newline = alloc((unsigned)(line_len + markerlen + STRLEN(cms) + 1));
+ newline = alloc(line_len + markerlen + STRLEN(cms) + 1);
if (newline == NULL)
return;
STRCPY(newline, line);
if (u_save(lnum - 1, lnum + 1) == OK)
{
/* Make new line: text-before-marker + text-after-marker */
- newline = alloc((unsigned)(STRLEN(line) - len + 1));
+ newline = alloc(STRLEN(line) - len + 1);
if (newline != NULL)
{
STRNCPY(newline, line, p - line);
/*
* Get here when adding a new entry to the maphash[] list or abbrlist.
*/
- mp = (mapblock_T *)alloc((unsigned)sizeof(mapblock_T));
+ mp = (mapblock_T *)alloc(sizeof(mapblock_T));
if (mp == NULL)
{
retval = 4; /* no mem */
if (round == 1)
{
- *file = (char_u **)alloc((unsigned)(count * sizeof(char_u *)));
+ *file = (char_u **)alloc(count * sizeof(char_u *));
if (*file == NULL)
return FAIL;
}
/* Need a buffer to hold up to three times as much. Four in case of an
* illegal utf-8 byte:
* 0xc0 -> 0xc3 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER */
- res = alloc((unsigned)(STRLEN(p) * 4) + 1);
+ res = alloc(STRLEN(p) * 4 + 1);
if (res != NULL)
{
d = res;
if (enc_utf8)
{
- buf = alloc((unsigned)(len * MB_MAXBYTES + 1));
+ buf = alloc(len * MB_MAXBYTES + 1);
if (buf == NULL)
return OK; /* not much we could do here... */
}
else if (enc_dbcs == DBCS_JPNU)
{
- buf = alloc((unsigned)(len * 2 + 1));
+ buf = alloc(len * 2 + 1);
if (buf == NULL)
return OK; /* not much we could do here... */
(unsigned)(Alloc * sizeof(SFLogin)));
}
len = strlen(pw->pw_name);
- entries[i].real = XtMalloc((unsigned) (len + 3));
+ entries[i].real = XtMalloc((unsigned)(len + 3));
(void) strcat(strcpy(entries[i].real, "~"), pw->pw_name);
entries[i].shown = entries[i].real;
entries[i].statDone = 1;
int len;
len = strlen(shown);
- entry->shown = XtMalloc((unsigned) (len + 2));
+ entry->shown = XtMalloc((unsigned)(len + 2));
(void) strcpy(entry->shown, shown);
SFwriteStatChar(entry->shown, len, &statBuf);
entry->shown[len + 1] = 0;
result[i].statDone = 0;
str = dp->d_name;
len = strlen(str);
- result[i].real = XtMalloc((unsigned) (len + 2));
+ result[i].real = XtMalloc((unsigned)(len + 2));
(void) strcat(strcpy(result[i].real, str), " ");
if (len > maxChars)
maxChars = len;
if (*psrc == '_')
++n_underscores;
- buf = alloc((unsigned)(psrc - name + n_underscores + 1));
+ buf = alloc(psrc - name + n_underscores + 1);
if (buf != NULL)
{
pdest = buf;
* into gui_argv. Freed later in gui_mch_init().
*/
gui_argc = 0;
- gui_argv = (char **)alloc((unsigned)((*argc + 1) * sizeof(char *)));
+ gui_argv = (char **)alloc((*argc + 1) * sizeof(char *));
g_return_if_fail(gui_argv != NULL);
if (info == (guint)TARGET_VIM)
{
- tmpbuf = alloc((unsigned)length + 1);
+ tmpbuf = alloc(length + 1);
if (tmpbuf != NULL)
{
tmpbuf[0] = motion_type;
int l = STRLEN(p_enc);
/* contents: motion_type 'encoding' NUL text */
- tmpbuf = alloc((unsigned)length + l + 2);
+ tmpbuf = alloc(length + l + 2);
if (tmpbuf != NULL)
{
tmpbuf[0] = motion_type;
if (i == count)
{
/* allocate an Atoms array which is one item longer */
- new_atoms = (Atom *)alloc((unsigned)((count + 1)
- * sizeof(Atom)));
+ new_atoms = (Atom *)alloc((count + 1) * sizeof(Atom));
if (new_atoms != NULL)
{
memcpy(new_atoms, existing_atoms, count * sizeof(Atom));
for (p = buts; *p; ++p)
if (*p == DLG_BUTTON_SEP)
++butcount;
- buttons = (Widget *)alloc((unsigned)(butcount * sizeof(Widget)));
+ buttons = (Widget *)alloc(butcount * sizeof(Widget));
if (buttons == NULL)
{
vim_free(buts);
charset_name = charset_id2name((int)lf.lfCharSet);
quality_name = quality_id2name((int)lf.lfQuality);
- res = (char *)alloc((unsigned)(strlen(font_name) + 30
+ res = (char *)alloc(strlen(font_name) + 30
+ (charset_name == NULL ? 0 : strlen(charset_name) + 2)
- + (quality_name == NULL ? 0 : strlen(quality_name) + 2)));
+ + (quality_name == NULL ? 0 : strlen(quality_name) + 2));
if (res != NULL)
{
p = res;
}
/* Allocate menu label and fill it in */
- text = label = alloc((unsigned)len + 1);
+ text = label = alloc(len + 1);
if (label == NULL)
break;
else
{
/* Allocate an array. */
- newarray = (hashitem_T *)alloc((unsigned)
- (sizeof(hashitem_T) * newsize));
+ newarray = (hashitem_T *)alloc(sizeof(hashitem_T) * newsize);
if (newarray == NULL)
{
/* Out of memory. When there are NULL items still return OK.
cs_stat_emsg(char *fname)
{
char *stat_emsg = _("E563: stat(%s) error: %d");
- char *buf = (char *)alloc((unsigned)strlen(stat_emsg) + MAXPATHL + 10);
+ char *buf = (char *)alloc(strlen(stat_emsg) + MAXPATHL + 10);
if (buf != NULL)
{
/* if filename is a directory, append the cscope database name to it */
if (S_ISDIR(statbuf.st_mode))
{
- fname2 = (char *)alloc((unsigned)(strlen(CSCOPE_DBFILE) + strlen(fname) + 2));
+ fname2 = (char *)alloc(strlen(CSCOPE_DBFILE) + strlen(fname) + 2);
if (fname2 == NULL)
goto add_err;
while VIM_ISWHITE(*pat)
++pat;
- if ((cmd = (char *)alloc((unsigned)(strlen(pat) + 2))) == NULL)
+ if ((cmd = (char *)alloc(strlen(pat) + 2)) == NULL)
return NULL;
(void)sprintf(cmd, "%d%s", search, pat);
if (strchr(CSQF_FLAGS, *qfpos) == NULL)
{
char *nf = _("E469: invalid cscopequickfix flag %c for %c");
- char *buf = (char *)alloc((unsigned)strlen(nf));
+ char *buf = (char *)alloc(strlen(nf));
/* strlen will be enough because we use chars */
if (buf != NULL)
return FALSE;
}
- buf = (char *)alloc((unsigned)(strlen(opt) + strlen(pat) + strlen(nf)));
+ buf = (char *)alloc(strlen(opt) + strlen(pat) + strlen(nf));
if (buf == NULL)
(void)emsg(nf);
else
clear_csinfo(j);
}
- if ((csinfo[i].fname = (char *)alloc((unsigned)strlen(fname)+1)) == NULL)
+ if ((csinfo[i].fname = (char *)alloc(strlen(fname)+1)) == NULL)
return -1;
(void)strcpy(csinfo[i].fname, (const char *)fname);
if (ppath != NULL)
{
- if ((csinfo[i].ppath = (char *)alloc((unsigned)strlen(ppath) + 1)) == NULL)
+ if ((csinfo[i].ppath = (char *)alloc(strlen(ppath) + 1)) == NULL)
{
VIM_CLEAR(csinfo[i].fname);
return -1;
if (flags != NULL)
{
- if ((csinfo[i].flags = (char *)alloc((unsigned)strlen(flags) + 1)) == NULL)
+ if ((csinfo[i].flags = (char *)alloc(strlen(flags) + 1)) == NULL)
{
VIM_CLEAR(csinfo[i].fname);
VIM_CLEAR(csinfo[i].ppath);
&slno, &search)) == NULL)
continue;
- context = (char *)alloc((unsigned)strlen(cntx)+5);
+ context = (char *)alloc(strlen(cntx)+5);
if (context == NULL)
continue;
assert(num_matches > 0);
- if ((tbuf = (char *)alloc((unsigned)strlen(matches[0]) + 1)) == NULL)
+ if ((tbuf = (char *)alloc(strlen(matches[0]) + 1)) == NULL)
return;
strcpy(tbuf, matches[0]);
* by parsing matches[i] on the fly and placing stuff into buf
* directly, but that's too much of a hassle
*/
- if ((tbuf = (char *)alloc((unsigned)strlen(matches[idx]) + 1)) == NULL)
+ if ((tbuf = (char *)alloc(strlen(matches[idx]) + 1)) == NULL)
continue;
(void)strcpy(tbuf, matches[idx]);
{
Sfdisc_t *disc;
- disc = (Sfdisc_t *)alloc((unsigned)sizeof(Sfdisc_t));
+ disc = (Sfdisc_t *)alloc(sizeof(Sfdisc_t));
if (disc == NULL)
return NULL;
Py_ssize_t len = strlen(str);
char *tmp,*p;
- tmp = (char *)alloc((unsigned)(len+1));
+ tmp = (char *)alloc(len + 1);
p = tmp;
if (p == NULL)
{
* Length must be computed exactly!
*/
length = STRLEN(name) + STRLEN(p_enc) + STRLEN(cmd) + 14;
- property = (char_u *)alloc((unsigned)length + 30);
+ property = (char_u *)alloc(length + 30);
sprintf((char *)property, "%c%c%c-n %s%c-E %s%c-s %s",
0, asExpr ? 'c' : 'k', 0, name, 0, p_enc, 0, cmd);
return -1;
length = STRLEN(p_enc) + STRLEN(str) + 14;
- if ((property = (char_u *)alloc((unsigned)length + 30)) != NULL)
+ if ((property = (char_u *)alloc(length + 30)) != NULL)
{
sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x",
0, 0, p_enc, 0, str, 0, (unsigned int)commWindow);
int len;
cinw_len = (int)STRLEN(curbuf->b_p_cinw) + 1;
- cinw_buf = alloc((unsigned)cinw_len);
+ cinw_buf = alloc(cinw_len);
if (cinw_buf != NULL)
{
line = skipwhite(line);
? actual_len : actual_compl_length;
// Allocate wide character array for the completion and fill it.
- wca = (int *)alloc((unsigned)(actual_len * sizeof(int)));
+ wca = (int *)alloc(actual_len * sizeof(int));
if (wca != NULL)
{
p = str;
if (pat_esc == NULL)
goto theend;
len = STRLEN(pat_esc) + 10;
- ptr = alloc((unsigned)len);
+ ptr = alloc(len);
if (ptr == NULL)
{
vim_free(pat_esc);
}
else
a = argv[0];
- p = alloc((unsigned)(STRLEN(a) + 4));
+ p = alloc(STRLEN(a) + 4);
if (p == NULL)
mch_exit(2);
sprintf((char *)p, "so %s", a);
* one. */
if (parmp->n_commands > 0)
{
- p = alloc((unsigned)STRLEN(parmp->commands[0]) + 3);
+ p = alloc(STRLEN(parmp->commands[0]) + 3);
if (p != NULL)
{
sprintf((char *)p, ":%s\r", parmp->commands[0]);
size_t len = STRLEN(cmd) + STRLEN(err) + 5;
char_u *msg;
- msg = alloc((unsigned)len);
+ msg = alloc(len);
if (msg != NULL)
vim_snprintf((char *)msg, len, "%s: \"%s\"", err, cmd);
*result = msg;
}
/* copy "enc" to allocated memory, with room for two '-' */
- r = alloc((unsigned)(STRLEN(enc) + 3));
+ r = alloc(STRLEN(enc) + 3);
if (r != NULL)
{
/* Make it all lower case and replace '_' with '-'. */
/* Allocate enough room for most conversions. When re-allocating
* increase the buffer size. */
len = len + fromlen * 2 + 40;
- p = alloc((unsigned)len);
+ p = alloc(len);
if (p != NULL && done > 0)
mch_memmove(p, result, done);
vim_free(result);
struct STATFS stf;
#endif
- if ((mfp = (memfile_T *)alloc((unsigned)sizeof(memfile_T))) == NULL)
+ if ((mfp = (memfile_T *)alloc(sizeof(memfile_T))) == NULL)
return NULL;
if (fname == NULL) /* no file for this memfile, use memory only */
{
bhdr_T *hp;
- if ((hp = (bhdr_T *)alloc((unsigned)sizeof(bhdr_T))) != NULL)
+ if ((hp = (bhdr_T *)alloc(sizeof(bhdr_T))) != NULL)
{
if ((hp->bh_data = (char_u *)alloc(mfp->mf_page_size * page_count))
== NULL)
if (hp->bh_bnum >= 0) /* it's already positive */
return OK;
- if ((np = (NR_TRANS *)alloc((unsigned)sizeof(NR_TRANS))) == NULL)
+ if ((np = (NR_TRANS *)alloc(sizeof(NR_TRANS))) == NULL)
return FAIL;
/*
* Allocate a buffer structure for the swap file that is used for recovery.
* Only the memline and crypt information in it are really used.
*/
- buf = (buf_T *)alloc((unsigned)sizeof(buf_T));
+ buf = (buf_T *)alloc(sizeof(buf_T));
if (buf == NULL)
goto theend;
* Do the loop for every directory in 'directory'.
* First allocate some memory to put the directory name in.
*/
- dir_name = alloc((unsigned)STRLEN(p_dir) + 1);
+ dir_name = alloc(STRLEN(p_dir) + 1);
dirp = p_dir;
while (dir_name != NULL && *dirp)
{
{
if (mch_stat((char *)swapname, &st) != -1) /* It exists! */
{
- files = (char_u **)alloc((unsigned)sizeof(char_u *));
+ files = (char_u **)alloc(sizeof(char_u *));
if (files != NULL)
{
files[0] = swapname;
f = fix_fname(name != NULL ? name : (char_u *)"");
if (f != NULL)
{
- s = alloc((unsigned)(STRLEN(f) + 1));
+ s = alloc(STRLEN(f) + 1);
if (s != NULL)
{
STRCPY(s, f);
if (new_prop_count == 0)
return; // nothing to do
new_len = *len + new_prop_count * sizeof(textprop_T);
- new_line = alloc((unsigned)new_len);
+ new_line = alloc(new_len);
if (new_line == NULL)
return;
mch_memmove(new_line, *line, *len);
{
CHECK(top > 0, _("Stack size increases")); /* more than 5 levels??? */
- newstack = (infoptr_T *)alloc((unsigned)sizeof(infoptr_T) *
+ newstack = (infoptr_T *)alloc(sizeof(infoptr_T) *
(buf->b_ml.ml_stack_size + STACK_INCR));
if (newstack == NULL)
return -1;
* Isolate a directory name from *dirp and put it in dir_name.
* First allocate some memory to put the directory name in.
*/
- dir_name = alloc((unsigned)STRLEN(*dirp) + 1);
+ dir_name = alloc(STRLEN(*dirp) + 1);
if (dir_name == NULL)
*dirp = NULL;
else
{
char_u *name;
- name = alloc((unsigned)(STRLEN(fname)
+ name = alloc(STRLEN(fname)
+ STRLEN(_("Swap file \""))
- + STRLEN(_("\" already exists!")) + 5));
+ + STRLEN(_("\" already exists!")) + 5);
if (name != NULL)
{
STRCPY(name, _("Swap file \""));
return;
if (buf->b_ml.ml_chunksize == NULL)
{
- buf->b_ml.ml_chunksize = (chunksize_T *)
- alloc((unsigned)sizeof(chunksize_T) * 100);
+ buf->b_ml.ml_chunksize =
+ (chunksize_T *)alloc(sizeof(chunksize_T) * 100);
if (buf->b_ml.ml_chunksize == NULL)
{
buf->b_ml.ml_usedchunks = -1;
* \'s and ^V's stripped out. But menu_path is a "raw"
* string, so we must correct for special characters.
*/
- tearpath = alloc((unsigned int)STRLEN(menu_path) + TEAR_LEN + 2);
+ tearpath = alloc(STRLEN(menu_path) + TEAR_LEN + 2);
if (tearpath != NULL)
{
char_u *s;
if (c != 0)
{
- menu->strings[i] = alloc((unsigned)(STRLEN(call_data) + 5 ));
+ menu->strings[i] = alloc(STRLEN(call_data) + 5);
if (menu->strings[i] != NULL)
{
menu->strings[i][0] = c;
menu = root_menu;
if (after_dot != arg)
{
- path_name = alloc((unsigned)(after_dot - arg));
+ path_name = alloc(after_dot - arg);
if (path_name == NULL)
return NULL;
vim_strncpy(path_name, arg, after_dot - arg - 1);
if (sourcing_name != NULL && other_sourcing_name())
{
p = (char_u *)_("Error detected while processing %s:");
- Buf = alloc((unsigned)(STRLEN(sourcing_name) + STRLEN(p)));
+ Buf = alloc(STRLEN(sourcing_name) + STRLEN(p));
if (Buf != NULL)
sprintf((char *)Buf, (char *)p, sourcing_name);
return Buf;
&& sourcing_lnum != 0)
{
p = (char_u *)_("line %4ld:");
- Buf = alloc((unsigned)(STRLEN(p) + 20));
+ Buf = alloc(STRLEN(p) + 20);
if (Buf != NULL)
sprintf((char *)Buf, (char *)p, (long)sourcing_lnum);
return Buf;
pend1 = remove_tail(p, pend, (char_u *)"MacOS");
if (pend1 != pend)
{
- pnew = alloc((unsigned)(pend1 - p) + 15);
+ pnew = alloc(pend1 - p + 15);
if (pnew != NULL)
{
STRNCPY(pnew, p, (pend1 - p));
* Putenv does not copy the string, it has to remain
* valid. The allocated memory will never be freed.
*/
- envbuf = alloc((unsigned)(STRLEN(name) + STRLEN(val) + 2));
+ envbuf = alloc(STRLEN(name) + STRLEN(val) + 2);
if (envbuf != NULL)
{
sprintf((char *)envbuf, "%s=%s", name, val);
{
char_u *dest;
- dest = alloc((unsigned)(STRLEN(fname1) + STRLEN(fname2) + 3));
+ dest = alloc(STRLEN(fname1) + STRLEN(fname2) + 3);
if (dest != NULL)
{
STRCPY(dest, fname1);
char_u *dest;
size_t l = STRLEN(str1);
- dest = alloc((unsigned)(l + STRLEN(str2) + 1L));
+ dest = alloc(l + STRLEN(str2) + 1L);
if (dest != NULL)
{
STRCPY(dest, str1);
if (fname == NULL)
return NULL;
- buf = alloc((unsigned)MAXPATHL);
+ buf = alloc(MAXPATHL);
if (buf != NULL)
{
if (vim_FullName(fname, buf, MAXPATHL, force) != FAIL)
if (ga_grow(gap, 1) == FAIL)
return;
- p = alloc((unsigned)(STRLEN(f) + 1 + isdir));
+ p = alloc(STRLEN(f) + 1 + isdir);
if (p == NULL)
return;
}
static void
-mem_pre_alloc_l(long_u *sizep)
+mem_pre_alloc_l(size_t *sizep)
{
*sizep += sizeof(size_t);
}
#ifdef FEAT_EVAL
int
-alloc_does_fail(long_u size)
+alloc_does_fail(size_t size)
{
if (alloc_fail_countdown == 0)
{
#define KEEP_ROOM_KB (KEEP_ROOM / 1024L)
/*
- * Note: if unsigned is 16 bits we can only allocate up to 64K with alloc().
- * Use lalloc for larger blocks.
+ * The normal way to allocate memory. This handles an out-of-memory situation
+ * as well as possible, still returns NULL when we're completely out.
*/
char_u *
-alloc(unsigned size)
+alloc(size_t size)
{
- return (lalloc((long_u)size, TRUE));
+ return lalloc(size, TRUE);
}
/*
* alloc() with an ID for alloc_fail().
*/
char_u *
-alloc_id(unsigned size, alloc_id_T id UNUSED)
+alloc_id(size_t size, alloc_id_T id UNUSED)
{
#ifdef FEAT_EVAL
- if (alloc_fail_id == id && alloc_does_fail((long_u)size))
+ if (alloc_fail_id == id && alloc_does_fail(size))
return NULL;
#endif
- return (lalloc((long_u)size, TRUE));
+ return lalloc(size, TRUE);
}
/*
* Allocate memory and set all bytes to zero.
*/
char_u *
-alloc_clear(unsigned size)
+alloc_clear(size_t size)
{
char_u *p;
- p = lalloc((long_u)size, TRUE);
+ p = lalloc(size, TRUE);
if (p != NULL)
- (void)vim_memset(p, 0, (size_t)size);
+ (void)vim_memset(p, 0, size);
return p;
}
* Same as alloc_clear() but with allocation id for testing
*/
char_u *
-alloc_clear_id(unsigned size, alloc_id_T id UNUSED)
+alloc_clear_id(size_t size, alloc_id_T id UNUSED)
{
#ifdef FEAT_EVAL
- if (alloc_fail_id == id && alloc_does_fail((long_u)size))
+ if (alloc_fail_id == id && alloc_does_fail(size))
return NULL;
#endif
return alloc_clear(size);
}
-/*
- * alloc() with check for maximum line length
- */
- char_u *
-alloc_check(unsigned size)
-{
-#if !defined(UNIX)
- if (sizeof(int) == 2 && size > 0x7fff)
- {
- /* Don't hide this message */
- emsg_silent = 0;
- emsg(_("E340: Line is becoming too long"));
- return NULL;
- }
-#endif
- return (lalloc((long_u)size, TRUE));
-}
-
/*
* Allocate memory like lalloc() and set all bytes to zero.
*/
char_u *
-lalloc_clear(long_u size, int message)
+lalloc_clear(size_t size, int message)
{
char_u *p;
p = (lalloc(size, message));
if (p != NULL)
- (void)vim_memset(p, 0, (size_t)size);
+ (void)vim_memset(p, 0, size);
return p;
}
* This is used often, KEEP IT FAST!
*/
char_u *
-lalloc(long_u size, int message)
+lalloc(size_t size, int message)
{
char_u *p; /* pointer to new storage space */
static int releasing = FALSE; /* don't do mf_release_all() recursive */
int try_again;
#if defined(HAVE_AVAIL_MEM)
- static long_u allocated = 0; /* allocated since last avail check */
+ static size_t allocated = 0; /* allocated since last avail check */
#endif
- /* Safety check for allocating zero bytes */
+ // Safety check for allocating zero bytes
if (size == 0)
{
- /* Don't hide this message */
+ // Don't hide this message
emsg_silent = 0;
- siemsg(_("E341: Internal error: lalloc(%ld, )"), size);
+ iemsg(_("E341: Internal error: lalloc(0, )"));
return NULL;
}
* allocating KEEP_ROOM amount of memory.
* 3. Strict check for available memory: call mch_avail_mem()
*/
- if ((p = (char_u *)malloc((size_t)size)) != NULL)
+ if ((p = (char_u *)malloc(size)) != NULL)
{
#ifndef HAVE_AVAIL_MEM
/* 1. No check for available memory: Just return. */
theend:
#ifdef MEM_PROFILE
- mem_post_alloc((void **)&p, (size_t)size);
+ mem_post_alloc((void **)&p, size);
#endif
return p;
}
*/
#if defined(FEAT_SIGNS) || defined(PROTO)
char_u *
-lalloc_id(long_u size, int message, alloc_id_T id UNUSED)
+lalloc_id(size_t size, int message, alloc_id_T id UNUSED)
{
#ifdef FEAT_EVAL
if (alloc_fail_id == id && alloc_does_fail(size))
return NULL;
#endif
- return (lalloc((long_u)size, message));
+ return (lalloc(size, message));
}
#endif
* Did_outofmem_msg is reset when a character is read.
*/
void
-do_outofmem_msg(long_u size)
+do_outofmem_msg(size_t size)
{
if (!did_outofmem_msg)
{
* message fails, e.g. when setting v:errmsg. */
did_outofmem_msg = TRUE;
- semsg(_("E342: Out of memory! (allocating %lu bytes)"), size);
+ semsg(_("E342: Out of memory! (allocating %lu bytes)"), (long_u)size);
}
}
vim_strsave(char_u *string)
{
char_u *p;
- unsigned len;
+ size_t len;
- len = (unsigned)STRLEN(string) + 1;
+ len = STRLEN(string) + 1;
p = alloc(len);
if (p != NULL)
- mch_memmove(p, string, (size_t)len);
+ mch_memmove(p, string, len);
return p;
}
{
char_u *p;
- p = alloc((unsigned)(len + 1));
+ p = alloc((size_t)(len + 1));
if (p != NULL)
{
STRNCPY(p, string, len);
* Returns NULL when out of memory.
*/
char_u *
-vim_memsave(char_u *p, int len)
+vim_memsave(char_u *p, size_t len)
{
- char_u *ret = alloc((unsigned)len);
+ char_u *ret = alloc(len);
if (ret != NULL)
- mch_memmove(ret, p, (size_t)len);
+ mch_memmove(ret, p, len);
return ret;
}
newl = utf_char2len(uc);
if (newl != l)
{
- s = alloc((unsigned)STRLEN(res) + 1 + newl - l);
+ s = alloc(STRLEN(res) + 1 + newl - l);
if (s == NULL)
{
vim_free(res);
newl = utf_char2len(lc);
if (newl != l)
{
- s = alloc((unsigned)STRLEN(res) + 1 + newl - l);
+ s = alloc(STRLEN(res) + 1 + newl - l);
if (s == NULL)
{
vim_free(res);
n = gap->ga_growsize;
new_len = gap->ga_itemsize * (gap->ga_len + n);
pp = (gap->ga_data == NULL)
- ? alloc((unsigned)new_len) : vim_realloc(gap->ga_data, new_len);
+ ? alloc(new_len) : vim_realloc(gap->ga_data, new_len);
if (pp == NULL)
return FAIL;
old_len = gap->ga_itemsize * gap->ga_maxlen;
if (ecmd == NULL)
ecmd = cmd;
}
- ncmd = alloc((unsigned)(STRLEN(ecmd) + STRLEN(p_sxq) * 2 + 1));
+ ncmd = alloc(STRLEN(ecmd) + STRLEN(p_sxq) * 2 + 1);
if (ncmd != NULL)
{
STRCPY(ncmd, p_sxq);
int i, j;
int gap;
- buf = alloc((unsigned)elm_size);
+ buf = alloc(elm_size);
if (buf == NULL)
return;
if (moreenv() < 0)
return -1;
}
- p = (char *)alloc((unsigned)(strlen(string) + 1));
+ p = (char *)alloc(strlen(string) + 1);
if (p == NULL) /* not enough core */
return -1;
environ[i + 1] = 0; /* new end of env. */
;
esize = i + EXTRASIZE + 1;
- env = (char **)alloc((unsigned)(esize * sizeof (elem)));
+ env = (char **)alloc(esize * sizeof (elem));
if (env == NULL)
return -1;
for (i = 0; environ[i]; i++)
{
- elem = (char *)alloc((unsigned)(strlen(environ[i]) + 1));
+ elem = (char *)alloc(strlen(environ[i]) + 1);
if (elem == NULL)
return -1;
env[i] = elem;
int c;
/* allocate memory */
- str = alloc((unsigned)cnt + 1);
+ str = alloc(cnt + 1);
if (str != NULL)
{
/* Read the string. Quit when running into the EOF. */
}
}
- *argv = (char **)alloc((unsigned)((*argc + 4) * sizeof(char *)));
+ *argv = (char **)alloc((*argc + 4) * sizeof(char *));
if (*argv == NULL) /* out of memory */
return FAIL;
}
nbdebug(("REP %d: %s\n", cmdno, (char *)result));
- reply = alloc((unsigned)STRLEN(result) + 32);
+ reply = alloc(STRLEN(result) + 32);
sprintf((char *)reply, "%d %s\n", cmdno, (char *)result);
nb_send((char *)reply, "nb_reply_text");
static char_u *
nb_quote(char_u *txt)
{
- char_u *buf = alloc((unsigned)(2 * STRLEN(txt) + 1));
+ char_u *buf = alloc(2 * STRLEN(txt) + 1);
char_u *p = txt;
char_u *q = buf;
len_first = (int)STRLEN(ml_get(first));
len_other = (int)STRLEN(ml_get(other));
- p = alloc((unsigned)(len_first + len_other + 1));
+ p = alloc(len_first + len_other + 1);
if (p != NULL)
{
mch_memmove(p, ml_get(first), len_first);
{
len = get_buf_size(buf->bufp);
nlines = buf->bufp->b_ml.ml_line_count;
- text = alloc((unsigned)((len > 0)
- ? ((len + nlines) * 2) : 4));
+ text = alloc((len > 0) ? ((len + nlines) * 2) : 4);
if (text == NULL)
{
nbdebug((" nb_do_cmd: getText has null text field\n"));
char_u *newline;
/* Insert halfway a line. */
- newline = alloc_check(
- (unsigned)(STRLEN(oldline) + len + 1));
+ newline = alloc(STRLEN(oldline) + len + 1);
if (newline != NULL)
{
mch_memmove(newline, oldline, (size_t)pos->col);
/* if we're splitting a TAB, allow for it */
bd.textcol -= bd.pre_whitesp_c - (bd.startspaces != 0);
len = (int)STRLEN(bd.textstart) + 1;
- newp = alloc_check((unsigned)(bd.textcol + i + j + len));
+ newp = alloc(bd.textcol + i + j + len);
if (newp == NULL)
return;
vim_memset(newp, NUL, (size_t)(bd.textcol + i + j + len));
+ fill
+ (unsigned)STRLEN(non_white) + 1;
- newp = alloc_check(new_line_len);
+ newp = alloc(new_line_len);
if (newp == NULL)
return;
mch_memmove(newp, oldp, (size_t)(verbatim_copy_end - oldp));
count -= off;
}
- newp = alloc_check((unsigned)(STRLEN(oldp)) + s_len + count + 1);
+ newp = alloc(STRLEN(oldp) + s_len + count + 1);
if (newp == NULL)
continue;
#endif
get_yank_register(name, 0);
- reg = (yankreg_T *)alloc((unsigned)sizeof(yankreg_T));
+ reg = (yankreg_T *)alloc(sizeof(yankreg_T));
if (reg != NULL)
{
*reg = *y_current;
if (reg->y_size == 0)
reg->y_array = NULL;
else
- reg->y_array = (char_u **)alloc((unsigned)(sizeof(char_u *)
- * reg->y_size));
+ reg->y_array = (char_u **)alloc(sizeof(char_u *) * reg->y_size);
if (reg->y_array != NULL)
{
for (i = 0; i < reg->y_size; ++i)
{
free_yank_all();
if ((y_current->y_array =
- (char_u **)alloc((unsigned)sizeof(char_u *))) == NULL)
+ (char_u **)alloc(sizeof(char_u *))) == NULL)
{
vim_free(p);
return FAIL;
// Thus the number of characters may increase!
n = bd.textlen - bd.startspaces - bd.endspaces;
oldp = ml_get(lnum);
- newp = alloc_check((unsigned)STRLEN(oldp) + 1 - n);
+ newp = alloc(STRLEN(oldp) + 1 - n);
if (newp == NULL)
continue;
/* copy up to deleted part */
oldp = ml_get_curline();
oldlen = STRLEN(oldp);
- newp = alloc_check((unsigned)oldlen + 1 + n);
+ newp = alloc(oldlen + 1 + n);
if (newp == NULL)
continue;
vim_memset(newp, NUL, (size_t)(oldlen + 1 + n));
else
{
/* Replacing with \r or \n means splitting the line. */
- after_p = alloc_check(
- (unsigned)(oldlen + 1 + n - STRLEN(newp)));
+ after_p = alloc(oldlen + 1 + n - STRLEN(newp));
if (after_p != NULL)
STRMOVE(after_p, oldp);
}
{
/* Subsequent calls to ml_get() flush the firstline data - take a
* copy of the inserted text. */
- if ((ins_text = alloc_check((unsigned)(ins_len + 1))) != NULL)
+ if ((ins_text = alloc(ins_len + 1)) != NULL)
{
vim_strncpy(ins_text, firstline + bd.textcol, (size_t)ins_len);
for (linenr = oap->start.lnum + 1; linenr <= oap->end.lnum;
else
vpos.coladd = 0;
oldp = ml_get(linenr);
- newp = alloc_check((unsigned)(STRLEN(oldp)
- + vpos.coladd + ins_len + 1));
+ newp = alloc(STRLEN(oldp) + vpos.coladd + ins_len + 1);
if (newp == NULL)
continue;
/* copy up to block start */
}
if (y_array != NULL)
break;
- y_array = (char_u **)alloc((unsigned)
- (y_size * sizeof(char_u *)));
+ y_array = (char_u **)alloc((y_size * sizeof(char_u *)));
if (y_array == NULL)
goto end;
}
/* insert the new text */
totlen = count * (yanklen + spaces) + bd.startspaces + bd.endspaces;
- newp = alloc_check((unsigned)totlen + oldlen + 1);
+ newp = alloc(totlen + oldlen + 1);
if (newp == NULL)
break;
/* copy part up to cursor to new line */
lnum++;
continue;
}
- newp = alloc_check((unsigned)(STRLEN(oldp) + totlen + 1));
+ newp = alloc(STRLEN(oldp) + totlen + 1);
if (newp == NULL)
goto end; /* alloc() gave an error message */
mch_memmove(newp, oldp, (size_t)col);
lnum = new_cursor.lnum;
ptr = ml_get(lnum) + col;
totlen = (int)STRLEN(y_array[y_size - 1]);
- newp = alloc_check((unsigned)(STRLEN(ptr) + totlen + 1));
+ newp = alloc(STRLEN(ptr) + totlen + 1);
if (newp == NULL)
goto error;
STRCPY(newp, y_array[y_size - 1]);
vim_free(newp);
oldp = ml_get(lnum);
- newp = alloc_check((unsigned)(col + yanklen + 1));
+ newp = alloc(col + yanklen + 1);
if (newp == NULL)
goto error;
/* copy first part of line */
col = sumsize - currsize - spaces[count - 1];
/* allocate the space for the new line */
- newp = alloc_check((unsigned)(sumsize + 1));
+ newp = alloc(sumsize + 1);
cend = newp + sumsize;
*cend = 0;
* When there are many leading zeros it could be very long.
* Allocate a bit too much.
*/
- buf1 = alloc((unsigned)length + NUMBUFLEN);
+ buf1 = alloc(length + NUMBUFLEN);
if (buf1 == NULL)
goto theend;
ptr = buf1;
*/
if (set_prev)
y_previous = y_current;
- array = (char_u **)alloc((unsigned)(limit * sizeof(char_u *)));
+ array = (char_u **)alloc(limit * sizeof(char_u *));
str = skipwhite(skiptowhite(str));
if (STRNCMP(str, "CHAR", 4) == 0)
new_type = MCHAR;
if (size == limit)
{
char_u **new_array = (char_u **)
- alloc((unsigned)(limit * 2 * sizeof(char_u *)));
+ alloc(limit * 2 * sizeof(char_u *));
if (new_array == NULL)
{
else
{
/* Move the lines from array[] to y_array[]. */
- y_current->y_array =
- (char_u **)alloc((unsigned)(size * sizeof(char_u *)));
+ y_current->y_array = (char_u **)alloc(size * sizeof(char_u *));
for (i = 0; i < size; i++)
{
if (y_current->y_array == NULL)
y_ptr->y_array = NULL;
return;
}
- y_ptr->y_array = (char_u **)alloc((unsigned)(linecount * sizeof(char_u *)));
+ y_ptr->y_array = (char_u **)alloc(linecount * sizeof(char_u *));
if (y_ptr->y_array == NULL)
{
y_ptr->y_size = 0; // ensure object state is consistent
}
else
extra = 0;
- s = alloc((unsigned)(i + extra + 1));
+ s = alloc(i + extra + 1);
if (s == NULL)
break;
if (extra)
cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
if (cdpath != NULL)
{
- buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
+ buf = alloc((STRLEN(cdpath) << 1) + 2);
if (buf != NULL)
{
buf[0] = ','; /* start with ",", current dir first */
wp->w_p_cc_cols = NULL;
else
{
- wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
+ wp->w_p_cc_cols = (int *)alloc(sizeof(int) * (count + 1));
if (wp->w_p_cc_cols != NULL)
{
/* sort the columns for faster usage on screen redraw inside
#define INC 20
#define GAP 3
- items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
- PARAM_COUNT));
+ items = (struct vimoption **)alloc(sizeof(struct vimoption *)
+ * PARAM_COUNT);
if (items == NULL)
return;
*num_file = num_term;
else
return OK;
- *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
+ *file = (char_u **)alloc(*num_file * sizeof(char_u *));
if (*file == NULL)
{
*file = (char_u **)"";
char_u *buf;
*num_file = 0;
- *file = (char_u **)alloc((unsigned)sizeof(char_u *));
+ *file = (char_u **)alloc(sizeof(char_u *));
if (*file == NULL)
return FAIL;
return FALSE;
}
- *array = (int *)alloc((unsigned) ((valcount + 1) * sizeof(int)));
+ *array = (int *)alloc((valcount + 1) * sizeof(int));
if (*array == NULL)
return FALSE;
(*array)[0] = valcount;
if (oldts == NULL)
return NULL;
- newts = (int *)alloc((unsigned)((oldts[0] + 1) * sizeof(int)));
+ newts = (int *)alloc((oldts[0] + 1) * sizeof(int));
if (newts != NULL)
for (t = 0; t <= oldts[0]; ++t)
newts[t] = oldts[t];
{
#endif
/* hack to replace '*' by '#?' */
- starbuf = alloc((unsigned)(2 * STRLEN(pat) + 1));
+ starbuf = alloc(2 * STRLEN(pat) + 1);
if (starbuf == NULL)
goto Return;
for (sp = pat, dp = starbuf; *sp; ++sp)
char_u *port_name = utf16_to_enc(wport_name, NULL);
if (printer_name != NULL && port_name != NULL)
- prt_name = alloc((unsigned)(STRLEN(printer_name)
- + STRLEN(port_name) + STRLEN(text)));
+ prt_name = alloc(STRLEN(printer_name)
+ + STRLEN(port_name) + STRLEN(text));
if (prt_name != NULL)
wsprintf((char *)prt_name, (const char *)text,
printer_name, port_name);
char *err = _(e_invexprmsg);
size_t len = STRLEN(str) + STRLEN(err) + 5;
- res = alloc((unsigned)len);
+ res = alloc(len);
if (res != NULL)
vim_snprintf((char *)res, len, "%s: \"%s\"", err, str);
reply.dwData = COPYDATA_ERROR_RESULT;
char_u *p;
/* Leave enough space for a 9-digit suffix to ensure uniqueness! */
- ok_name = alloc((unsigned)STRLEN(name) + 10);
+ ok_name = alloc(STRLEN(name) + 10);
STRCPY(ok_name, name);
p = ok_name + STRLEN(name);
#endif
/*
- * Get name of current directory into buffer 'buf' of length 'len' bytes.
+ * Get name of current directory into buffer "buf" of length "len" bytes.
+ * "len" must be at least PATH_MAX.
* Return OK for success, FAIL for failure.
*/
int
{
/*
* If the file name has a path, change to that directory for a moment,
- * and then do the getwd() (and get back to where we were).
+ * and then get the directory (and get back to where we were).
* This will get the correct path name with "../" things.
*/
if (p != NULL)
p = (char_u *)getenv("PATH");
if (p == NULL || *p == NUL)
return -1;
- buf = alloc((unsigned)(STRLEN(name) + STRLEN(p) + 2));
+ buf = alloc(STRLEN(name) + STRLEN(p) + 2);
if (buf == NULL)
return -1;
/* Break 'shellcmdflag' into white separated parts. This doesn't
* handle quoted strings, they are very unlikely to appear. */
- *shcf_tofree = alloc((unsigned)STRLEN(p_shcf) + 1);
+ *shcf_tofree = alloc(STRLEN(p_shcf) + 1);
if (*shcf_tofree == NULL) /* out of memory */
return FAIL;
s = *shcf_tofree;
&& !mch_can_exe((*file)[i], NULL, !(flags & EW_SHELLCMD)))
continue;
- p = alloc((unsigned)(STRLEN((*file)[i]) + 1 + dir));
+ p = alloc(STRLEN((*file)[i]) + 1 + dir);
if (p)
{
STRCPY(p, (*file)[i]);
if (sys$trnlnm(&attrib, &d_file_dev, &d_lognam, NULL,&itmlst) == SS$_NORMAL)
{
buffer[lengte] = '\0';
- if (cp = (char_u *)alloc((unsigned)(lengte+1)))
+ if (cp = (char_u *)alloc(lengte + 1))
strcpy((char *)cp, buffer);
return(cp);
}
return FALSE;
wcurpath = _wgetenv(L"PATH");
- wnewpath = (WCHAR*)alloc((unsigned)(wcslen(wcurpath) + 3)
- * sizeof(WCHAR));
+ wnewpath = (WCHAR *)alloc((wcslen(wcurpath) + 3) * sizeof(WCHAR));
if (wnewpath == NULL)
return FALSE;
wcscpy(wnewpath, L".;");
char_u *envbuf;
WCHAR *p;
- envbuf = alloc((unsigned)(STRLEN(var) + STRLEN(value) + 2));
+ envbuf = alloc(STRLEN(var) + STRLEN(value) + 2);
if (envbuf == NULL)
return -1;
void adjust_cursor_col(void);
int leftcol_changed(void);
void vim_mem_profile_dump(void);
-int alloc_does_fail(long_u size);
-char_u *alloc(unsigned size);
-char_u *alloc_id(unsigned size, alloc_id_T id);
-char_u *alloc_clear(unsigned size);
-char_u *alloc_clear_id(unsigned size, alloc_id_T id);
-char_u *alloc_check(unsigned size);
-char_u *lalloc_clear(long_u size, int message);
-char_u *lalloc(long_u size, int message);
-char_u *lalloc_id(long_u size, int message, alloc_id_T id);
+int alloc_does_fail(size_t size);
+char_u *alloc(size_t size);
+char_u *alloc_id(size_t size, alloc_id_T id);
+char_u *alloc_clear(size_t size);
+char_u *alloc_clear_id(size_t size, alloc_id_T id);
+char_u *lalloc_clear(size_t size, int message);
+char_u *lalloc(size_t size, int message);
+char_u *lalloc_id(size_t size, int message, alloc_id_T id);
void *mem_realloc(void *ptr, size_t size);
-void do_outofmem_msg(long_u size);
+void do_outofmem_msg(size_t size);
void free_all_mem(void);
char_u *vim_strsave(char_u *string);
char_u *vim_strnsave(char_u *string, int len);
-char_u *vim_memsave(char_u *p, int len);
+char_u *vim_memsave(char_u *p, size_t len);
char_u *vim_strsave_escaped(char_u *string, char_u *esc_chars);
char_u *vim_strsave_escaped_ext(char_u *string, char_u *esc_chars, int cc, int bsl);
int csh_like_shell(void);
if (*fields->errmsg && !qfl->qf_multiignore)
{
len = (int)STRLEN(qfprev->qf_text);
- if ((ptr = alloc((unsigned)(len + STRLEN(fields->errmsg) + 2)))
+ if ((ptr = alloc(len + STRLEN(fields->errmsg) + 2))
== NULL)
return QF_FAIL;
STRCPY(ptr, qfprev->qf_text);
{
qf_delq_T *q;
- q = (qf_delq_T *)alloc((unsigned)sizeof(qf_delq_T));
+ q = (qf_delq_T *)alloc(sizeof(qf_delq_T));
if (q != NULL)
{
q->qi = qi;
qfline_T *qfp;
qfline_T **lastp; // pointer to qf_last or NULL
- if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL)
+ if ((qfp = (qfline_T *)alloc(sizeof(qfline_T))) == NULL)
return QF_FAIL;
if (bufnum != 0)
{
struct dir_stack_T *ds_ptr;
// allocate new stack element and hook it in
- ds_new = (struct dir_stack_T *)alloc((unsigned)sizeof(struct dir_stack_T));
+ ds_new = (struct dir_stack_T *)alloc(sizeof(struct dir_stack_T));
if (ds_new == NULL)
return NULL;
else
off += 19;
- name = alloc((unsigned)STRLEN(p_mef) + 30);
+ name = alloc(STRLEN(p_mef) + 30);
if (name == NULL)
break;
STRCPY(name, p_mef);
{
/* length = len(newsub) - 1 + len(prev_sub) + 1 */
prevlen = (int)STRLEN(reg_prev_sub);
- tmpsub = alloc((unsigned)(STRLEN(newsub) + prevlen));
+ tmpsub = alloc(STRLEN(newsub) + prevlen);
if (tmpsub != NULL)
{
/* copy prefix */
if (n_extra > 0)
len += n_extra - tab_len;
c = lcs_tab1;
- p = alloc((unsigned)(len + 1));
+ p = alloc(len + 1);
vim_memset(p, ' ', len);
p[len] = NUL;
vim_free(p_extra_free);
char_u *p;
c = *p_extra;
- p = alloc((unsigned)n_extra + 1);
+ p = alloc(n_extra + 1);
vim_memset(p, ' ', n_extra);
STRNCPY(p, p_extra + 1, STRLEN(p_extra) - 1);
p[n_extra] = NUL;
return;
if (has_mbyte)
- buf = alloc((unsigned)Columns * MB_MAXBYTES + 1);
+ buf = alloc(Columns * MB_MAXBYTES + 1);
else
- buf = alloc((unsigned)Columns + 1);
+ buf = alloc(Columns + 1);
if (buf == NULL)
return;
hi = hash_lookup(&lp->sl_wordcount, p, hash);
if (HASHITEM_EMPTY(hi))
{
- wc = (wordcount_T *)alloc((unsigned)(sizeof(wordcount_T) + STRLEN(p)));
+ wc = (wordcount_T *)alloc(sizeof(wordcount_T) + STRLEN(p));
if (wc == NULL)
return;
STRCPY(wc->wc_word, p);
}
/* Replace the word. */
- p = alloc((unsigned)STRLEN(line) - stp->st_orglen
- + stp->st_wordlen + 1);
+ p = alloc(STRLEN(line) - stp->st_orglen + stp->st_wordlen + 1);
if (p != NULL)
{
c = (int)(sug.su_badptr - line);
}
addlen = (int)(STRLEN(repl_to) - STRLEN(repl_from));
- frompat = alloc((unsigned)STRLEN(repl_from) + 7);
+ frompat = alloc(STRLEN(repl_from) + 7);
if (frompat == NULL)
return;
sprintf((char *)frompat, "\\V\\<%s\\>", repl_from);
if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col,
repl_to, STRLEN(repl_to)) != 0)
{
- p = alloc((unsigned)STRLEN(line) + addlen + 1);
+ p = alloc(STRLEN(line) + addlen + 1);
if (p == NULL)
break;
mch_memmove(p, line, curwin->w_cursor.col);
hi = hash_lookup(&slang->sl_sounddone, goodword, hash);
if (HASHITEM_EMPTY(hi))
{
- sft = (sftword_T *)alloc((unsigned)(sizeof(sftword_T)
- + STRLEN(goodword)));
+ sft = (sftword_T *)alloc(sizeof(sftword_T) + STRLEN(goodword));
if (sft != NULL)
{
sft->sft_score = score;
c = todo * 2 + 7;
if (enc_utf8)
c += todo * 2;
- pat = alloc((unsigned)c);
+ pat = alloc(c);
if (pat == NULL)
return SP_OTHERERROR;
hash_T hash;
hashitem_T *hi;
- b = alloc((unsigned)(cl + headcl + 2));
+ b = alloc(cl + headcl + 2);
if (b == NULL)
return;
mb_char2bytes(c, b);
if (curwin->w_s->b_syn_topgrp >= SYNID_CLUSTER)
{
/* We have to alloc this, because syn_combine_list() will free it. */
- short *grp_list = (short *)alloc((unsigned)(2 * sizeof(short)));
+ short *grp_list = (short *)alloc(2 * sizeof(short));
int tlg_id = curwin->w_s->b_syn_topgrp - SYNID_CLUSTER;
if (grp_list != NULL)
syn_id = syn_check_group(arg, (int)(group_name_end - arg));
if (syn_id != 0)
/* allocate a buffer, for removing backslashes in the keyword */
- keyword_copy = alloc((unsigned)STRLEN(rest) + 1);
+ keyword_copy = alloc(STRLEN(rest) + 1);
if (keyword_copy != NULL)
{
syn_opt_arg.flags = 0;
* syn_patterns for this item, at the start (because the list is
* used from end to start).
*/
- ppp = (struct pat_ptr *)alloc((unsigned)sizeof(struct pat_ptr));
+ ppp = (struct pat_ptr *)alloc(sizeof(struct pat_ptr));
if (ppp == NULL)
{
rest = NULL;
clstr = NULL;
break;
}
- clstr = (short *)alloc((unsigned)((count + 1) * sizeof(short)));
+ clstr = (short *)alloc((count + 1) * sizeof(short));
if (clstr == NULL)
break;
clstr[count] = 0;
break;
if (round == 1)
{
- retval = (short *)alloc((unsigned)((count + 1) * sizeof(short)));
+ retval = (short *)alloc((count + 1) * sizeof(short));
if (retval == NULL)
break;
retval[count] = 0; /* zero means end of the list */
for (count = 0; list[count]; ++count)
;
len = (count + 1) * sizeof(short);
- retval = (short *)alloc((unsigned)len);
+ retval = (short *)alloc(len);
if (retval != NULL)
mch_memmove(retval, list, (size_t)len);
return OK;
recursive = TRUE;
- buf = alloc((unsigned)(STRLEN(name) + 12));
+ buf = alloc(STRLEN(name) + 12);
if (buf != NULL)
{
apply_autocmds(EVENT_COLORSCHEMEPRE, name,
* Allocate space for the translation. Worst case a single character is
* replaced by 6 bytes (shifted special key), plus a NUL at the end.
*/
- result = alloc((unsigned)STRLEN(from) * 6 + 1);
+ result = alloc(STRLEN(from) * 6 + 1);
if (result == NULL) /* out of memory */
{
*bufp = NULL;
if (tc_len == 0) /* no terminal codes (must be GUI) */
return;
- items = (int *)alloc((unsigned)(sizeof(int) * tc_len));
+ items = (int *)alloc(sizeof(int) * tc_len);
if (items == NULL)
return;
}
else
{
+ // This uses the length in the memline, thus text properties are
+ // included.
ul->ul_len = curbuf->b_ml.ml_line_len;
ul->ul_line = vim_memsave(line, ul->ul_len);
}
static char_u *
read_string_decrypt(bufinfo_T *bi, int len)
{
- char_u *ptr = alloc((unsigned)len + 1);
+ char_u *ptr = alloc(len + 1);
if (ptr != NULL)
{
char_u *p = ml_get(top + 1 + i);
if (curbuf->b_ml.ml_line_len != uep->ue_array[i].ul_len
- || memcmp(uep->ue_array[i].ul_line, p, curbuf->b_ml.ml_line_len) != 0)
+ || memcmp(uep->ue_array[i].ul_line, p,
+ curbuf->b_ml.ml_line_len) != 0)
break;
}
if (i == newsize && newlnum == MAXLNUM && uep->ue_next == NULL)
// If the file is empty, there is an empty line 1 that we
// should get rid of, by replacing it with the new line.
if (empty_buffer && lnum == 0)
- ml_replace_len((linenr_T)1, uep->ue_array[i].ul_line, uep->ue_array[i].ul_len, TRUE, TRUE);
+ ml_replace_len((linenr_T)1, uep->ue_array[i].ul_line,
+ uep->ue_array[i].ul_len, TRUE, TRUE);
else
- ml_append(lnum, uep->ue_array[i].ul_line, (colnr_T)uep->ue_array[i].ul_len, FALSE);
+ ml_append(lnum, uep->ue_array[i].ul_line,
+ (colnr_T)uep->ue_array[i].ul_len, FALSE);
vim_free(uep->ue_array[i].ul_line);
}
vim_free((char_u *)uep->ue_array);
}
totlen += STRLEN(p); // Add on the trailing characters
- buf = alloc((unsigned)(totlen + 1));
+ buf = alloc(totlen + 1);
if (buf == NULL)
{
vim_free(split_buf);
}
else
{
- fname = alloc((unsigned)(i + STRLEN(name + llen) + 1));
+ fname = alloc(i + STRLEN(name + llen) + 1);
if (fname == NULL)
*error = ERROR_OTHER;
else
/* need space for function name + ("function " + 3) or "[number]" */
len = (save_sourcing_name == NULL ? 0 : STRLEN(save_sourcing_name))
+ STRLEN(fp->uf_name) + 20;
- sourcing_name = alloc((unsigned)len);
+ sourcing_name = alloc(len);
if (sourcing_name != NULL)
{
if (save_sourcing_name != NULL
}
}
- name = alloc((unsigned)(len + lead + 1));
+ name = alloc(len + lead + 1);
if (name != NULL)
{
if (lead > 0)
if (todo == 0)
return; /* nothing to dump */
- sorttab = (ufunc_T **)alloc((unsigned)(sizeof(ufunc_T *) * todo));
+ sorttab = (ufunc_T **)alloc(sizeof(ufunc_T *) * todo);
for (hi = func_hashtab.ht_array; todo > 0; ++hi)
{
+ strlen(VIM_VERSION_DATE_ONLY)
+ strlen(date_time);
- longVersion = (char *)alloc((unsigned)len);
+ longVersion = (char *)alloc(len);
if (longVersion == NULL)
longVersion = VIM_VERSION_LONG;
else
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1384,
/**/
1383,
/**/
{
*outlen = WideCharToMultiByte(cp, flags, in, inlen, NULL, 0, def, useddef);
/* Add one one byte to avoid a zero-length alloc(). */
- *out = (LPSTR)alloc((unsigned)*outlen + 1);
+ *out = (LPSTR)alloc(*outlen + 1);
if (*out != NULL)
{
WideCharToMultiByte(cp, flags, in, inlen, *out, *outlen, def, useddef);
metadata.txtlen = WideCharToMultiByte(GetACP(), 0, out, len,
NULL, 0, 0, 0);
vim_free(str);
- str = (char_u *)alloc((unsigned)(metadata.txtlen == 0 ? 1
- : metadata.txtlen));
+ str = (char_u *)alloc(metadata.txtlen == 0 ? 1 : metadata.txtlen);
if (str == NULL)
{
vim_free(out);
convert_setup(&conv, NULL, NULL);
length = utf8_to_utf16(str, *lenp, NULL, NULL);
- ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
+ ret = (WCHAR *)alloc((length + 1) * sizeof(WCHAR));
if (ret != NULL)
{
utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);