mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Replace alloc() with xmalloc() and remove immediate OOM checks
This commit is contained in:
parent
a80d7e86c1
commit
21784aeb00
@ -1738,28 +1738,24 @@ char_u* keymap_init(void)
|
||||
keymap_unload();
|
||||
do_cmdline_cmd((char_u *)"unlet! b:keymap_name");
|
||||
} else {
|
||||
char_u *buf;
|
||||
char *buf;
|
||||
size_t buflen;
|
||||
|
||||
// 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);
|
||||
|
||||
if (buf == NULL) {
|
||||
return e_outofmem;
|
||||
}
|
||||
buf = xmalloc(buflen);
|
||||
|
||||
// try finding "keymap/'keymap'_'encoding'.vim" in 'runtimepath'
|
||||
vim_snprintf((char *)buf, buflen, "keymap/%s_%s.vim",
|
||||
vim_snprintf(buf, buflen, "keymap/%s_%s.vim",
|
||||
curbuf->b_p_keymap, p_enc);
|
||||
|
||||
if (source_runtime(buf, FALSE) == FAIL) {
|
||||
if (source_runtime((char_u *)buf, FALSE) == FAIL) {
|
||||
// try finding "keymap/'keymap'.vim" in 'runtimepath'
|
||||
vim_snprintf((char *)buf, buflen, "keymap/%s.vim",
|
||||
vim_snprintf(buf, buflen, "keymap/%s.vim",
|
||||
curbuf->b_p_keymap);
|
||||
|
||||
if (source_runtime(buf, FALSE) == FAIL) {
|
||||
if (source_runtime((char_u *)buf, FALSE) == FAIL) {
|
||||
free(buf);
|
||||
return (char_u *)N_("E544: Keymap file not found");
|
||||
}
|
||||
|
353
src/nvim/eval.c
353
src/nvim/eval.c
@ -1456,12 +1456,11 @@ int get_spellword(list_T *list, char_u **pp)
|
||||
*/
|
||||
typval_T *eval_expr(char_u *arg, char_u **nextcmd)
|
||||
{
|
||||
typval_T *tv;
|
||||
typval_T *tv = xmalloc(sizeof(typval_T));
|
||||
|
||||
tv = (typval_T *)alloc(sizeof(typval_T));
|
||||
if (tv != NULL && eval0(arg, tv, nextcmd, TRUE) == FAIL) {
|
||||
if (eval0(arg, tv, nextcmd, TRUE) == FAIL) {
|
||||
free(tv);
|
||||
tv = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return tv;
|
||||
@ -1484,7 +1483,6 @@ call_vim_function (
|
||||
typval_T *rettv
|
||||
)
|
||||
{
|
||||
typval_T *argvars;
|
||||
long n;
|
||||
int len;
|
||||
int i;
|
||||
@ -1492,9 +1490,7 @@ call_vim_function (
|
||||
void *save_funccalp = NULL;
|
||||
int ret;
|
||||
|
||||
argvars = (typval_T *)alloc((unsigned)((argc + 1) * sizeof(typval_T)));
|
||||
if (argvars == NULL)
|
||||
return FAIL;
|
||||
typval_T *argvars = xmalloc((argc + 1) * sizeof(typval_T));
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
/* Pass a NULL or empty argument as an empty string */
|
||||
@ -3426,20 +3422,19 @@ void del_menutrans_vars(void)
|
||||
static char_u *cat_prefix_varname(int prefix, char_u *name);
|
||||
|
||||
static char_u *varnamebuf = NULL;
|
||||
static int varnamebuflen = 0;
|
||||
static size_t varnamebuflen = 0;
|
||||
|
||||
/*
|
||||
* Function to concatenate a prefix and a variable name.
|
||||
*/
|
||||
static char_u *cat_prefix_varname(int prefix, char_u *name)
|
||||
{
|
||||
int len;
|
||||
size_t len = STRLEN(name) + 3;
|
||||
|
||||
len = (int)STRLEN(name) + 3;
|
||||
if (len > varnamebuflen) {
|
||||
free(varnamebuf);
|
||||
len += 10; /* some additional space */
|
||||
varnamebuf = alloc(len);
|
||||
varnamebuf = xmalloc(len);
|
||||
if (varnamebuf == NULL) {
|
||||
varnamebuflen = 0;
|
||||
return NULL;
|
||||
@ -4921,9 +4916,7 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
|
||||
* Copy the string into allocated memory, handling backslashed
|
||||
* characters.
|
||||
*/
|
||||
name = alloc((unsigned)(p - *arg + extra));
|
||||
if (name == NULL)
|
||||
return FAIL;
|
||||
name = xmalloc(p - *arg + extra);
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = name;
|
||||
|
||||
@ -5038,9 +5031,7 @@ static int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate)
|
||||
/*
|
||||
* Copy the string into allocated memory, handling '' to ' reduction.
|
||||
*/
|
||||
str = alloc((unsigned)((p - *arg) - reduce));
|
||||
if (str == NULL)
|
||||
return FAIL;
|
||||
str = xmalloc((p - *arg) - reduce);
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = str;
|
||||
|
||||
@ -5189,7 +5180,7 @@ list_free (
|
||||
*/
|
||||
listitem_T *listitem_alloc(void)
|
||||
{
|
||||
return (listitem_T *)alloc(sizeof(listitem_T));
|
||||
return xmalloc(sizeof(listitem_T));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -6154,17 +6145,12 @@ dict_free (
|
||||
* Allocate a Dictionary item.
|
||||
* The "key" is copied to the new item.
|
||||
* Note that the value of the item "di_tv" still needs to be initialized!
|
||||
* Returns NULL when out of memory.
|
||||
*/
|
||||
dictitem_T *dictitem_alloc(char_u *key)
|
||||
{
|
||||
dictitem_T *di;
|
||||
|
||||
di = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T) + STRLEN(key)));
|
||||
if (di != NULL) {
|
||||
STRCPY(di->di_key, key);
|
||||
di->di_flags = 0;
|
||||
}
|
||||
dictitem_T *di = xmalloc(sizeof(dictitem_T) + STRLEN(key));
|
||||
STRCPY(di->di_key, key);
|
||||
di->di_flags = 0;
|
||||
return di;
|
||||
}
|
||||
|
||||
@ -6173,15 +6159,12 @@ dictitem_T *dictitem_alloc(char_u *key)
|
||||
*/
|
||||
static dictitem_T *dictitem_copy(dictitem_T *org)
|
||||
{
|
||||
dictitem_T *di;
|
||||
dictitem_T *di = xmalloc(sizeof(dictitem_T) + STRLEN(org->di_key));
|
||||
|
||||
STRCPY(di->di_key, org->di_key);
|
||||
di->di_flags = 0;
|
||||
copy_tv(&org->di_tv, &di->di_tv);
|
||||
|
||||
di = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T)
|
||||
+ STRLEN(org->di_key)));
|
||||
if (di != NULL) {
|
||||
STRCPY(di->di_key, org->di_key);
|
||||
di->di_flags = 0;
|
||||
copy_tv(&org->di_tv, &di->di_tv);
|
||||
}
|
||||
return di;
|
||||
}
|
||||
|
||||
@ -6668,34 +6651,33 @@ static char_u *tv2string(typval_T *tv, char_u **tofree, char_u *numbuf, int copy
|
||||
*/
|
||||
static char_u *string_quote(char_u *str, int function)
|
||||
{
|
||||
unsigned len;
|
||||
char_u *p, *r, *s;
|
||||
|
||||
len = (function ? 13 : 3);
|
||||
size_t len = (function ? 13 : 3);
|
||||
if (str != NULL) {
|
||||
len += (unsigned)STRLEN(str);
|
||||
len += STRLEN(str);
|
||||
for (p = str; *p != NUL; mb_ptr_adv(p))
|
||||
if (*p == '\'')
|
||||
++len;
|
||||
}
|
||||
s = r = alloc(len);
|
||||
if (r != NULL) {
|
||||
if (function) {
|
||||
STRCPY(r, "function('");
|
||||
r += 10;
|
||||
} else
|
||||
*r++ = '\'';
|
||||
if (str != NULL)
|
||||
for (p = str; *p != NUL; ) {
|
||||
if (*p == '\'')
|
||||
*r++ = '\'';
|
||||
MB_COPY_CHAR(p, r);
|
||||
}
|
||||
s = r = xmalloc(len);
|
||||
|
||||
if (function) {
|
||||
STRCPY(r, "function('");
|
||||
r += 10;
|
||||
} else
|
||||
*r++ = '\'';
|
||||
if (function)
|
||||
*r++ = ')';
|
||||
*r++ = NUL;
|
||||
}
|
||||
if (str != NULL)
|
||||
for (p = str; *p != NUL; ) {
|
||||
if (*p == '\'')
|
||||
*r++ = '\'';
|
||||
MB_COPY_CHAR(p, r);
|
||||
}
|
||||
*r++ = '\'';
|
||||
if (function)
|
||||
*r++ = ')';
|
||||
*r++ = NUL;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -7282,13 +7264,9 @@ call_func (
|
||||
STRCPY(fname_buf + i, name + llen);
|
||||
fname = fname_buf;
|
||||
} else {
|
||||
fname = alloc((unsigned)(i + STRLEN(name + llen) + 1));
|
||||
if (fname == NULL)
|
||||
error = ERROR_OTHER;
|
||||
else {
|
||||
memmove(fname, fname_buf, (size_t)i);
|
||||
STRCPY(fname + i, name + llen);
|
||||
}
|
||||
fname = xmalloc(i + STRLEN(name + llen) + 1);
|
||||
memmove(fname, fname_buf, (size_t)i);
|
||||
STRCPY(fname + i, name + llen);
|
||||
}
|
||||
} else
|
||||
fname = name;
|
||||
@ -9251,20 +9229,18 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
}
|
||||
txt = _("+-%s%3ld lines: ");
|
||||
r = alloc((unsigned)(STRLEN(txt)
|
||||
+ STRLEN(vimvars[VV_FOLDDASHES].vv_str) /* for %s */
|
||||
+ 20 /* for %3ld */
|
||||
+ STRLEN(s))); /* concatenated */
|
||||
if (r != NULL) {
|
||||
sprintf((char *)r, txt, vimvars[VV_FOLDDASHES].vv_str,
|
||||
(long)((linenr_T)vimvars[VV_FOLDEND].vv_nr
|
||||
- (linenr_T)vimvars[VV_FOLDSTART].vv_nr + 1));
|
||||
len = (int)STRLEN(r);
|
||||
STRCAT(r, s);
|
||||
/* remove 'foldmarker' and 'commentstring' */
|
||||
foldtext_cleanup(r + len);
|
||||
rettv->vval.v_string = r;
|
||||
}
|
||||
r = xmalloc(STRLEN(txt)
|
||||
+ STRLEN(vimvars[VV_FOLDDASHES].vv_str) // for %s
|
||||
+ 20 // for %3ld
|
||||
+ STRLEN(s)); // concatenated
|
||||
sprintf((char *)r, txt, vimvars[VV_FOLDDASHES].vv_str,
|
||||
(long)((linenr_T)vimvars[VV_FOLDEND].vv_nr
|
||||
- (linenr_T)vimvars[VV_FOLDSTART].vv_nr + 1));
|
||||
len = (int)STRLEN(r);
|
||||
STRCAT(r, s);
|
||||
/* remove 'foldmarker' and 'commentstring' */
|
||||
foldtext_cleanup(r + len);
|
||||
rettv->vval.v_string = r;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9325,12 +9301,9 @@ static void f_function(typval_T *argvars, typval_T *rettv)
|
||||
* would also work, but some plugins depend on the name being
|
||||
* printable text. */
|
||||
sprintf(sid_buf, "<SNR>%" PRId64 "_", (int64_t)current_SID);
|
||||
rettv->vval.v_string =
|
||||
alloc((int)(STRLEN(sid_buf) + STRLEN(s + off) + 1));
|
||||
if (rettv->vval.v_string != NULL) {
|
||||
STRCPY(rettv->vval.v_string, sid_buf);
|
||||
STRCAT(rettv->vval.v_string, s + off);
|
||||
}
|
||||
rettv->vval.v_string = xmalloc(STRLEN(sid_buf) + STRLEN(s + off) + 1);
|
||||
STRCPY(rettv->vval.v_string, sid_buf);
|
||||
STRCAT(rettv->vval.v_string, s + off);
|
||||
} else
|
||||
rettv->vval.v_string = vim_strsave(s);
|
||||
rettv->v_type = VAR_FUNC;
|
||||
@ -9619,11 +9592,9 @@ static void f_getcmdpos(typval_T *argvars, typval_T *rettv)
|
||||
static void f_getcmdtype(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = alloc(2);
|
||||
if (rettv->vval.v_string != NULL) {
|
||||
rettv->vval.v_string[0] = get_cmdline_type();
|
||||
rettv->vval.v_string[1] = NUL;
|
||||
}
|
||||
rettv->vval.v_string = xmalloc(2);
|
||||
rettv->vval.v_string[0] = get_cmdline_type();
|
||||
rettv->vval.v_string[1] = NUL;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -9635,17 +9606,14 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv)
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
cwd = alloc(MAXPATHL);
|
||||
if (cwd != NULL) {
|
||||
if (os_dirname(cwd, MAXPATHL) != FAIL) {
|
||||
rettv->vval.v_string = vim_strsave(cwd);
|
||||
cwd = xmalloc(MAXPATHL);
|
||||
if (os_dirname(cwd, MAXPATHL) != FAIL) {
|
||||
rettv->vval.v_string = vim_strsave(cwd);
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
if (rettv->vval.v_string != NULL)
|
||||
slash_adjust(rettv->vval.v_string);
|
||||
slash_adjust(rettv->vval.v_string);
|
||||
#endif
|
||||
}
|
||||
free(cwd);
|
||||
}
|
||||
free(cwd);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -11962,7 +11930,6 @@ static void f_printf(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
char_u buf[NUMBUFLEN];
|
||||
int len;
|
||||
char_u *s;
|
||||
int saved_did_emsg = did_emsg;
|
||||
char *fmt;
|
||||
|
||||
@ -11971,11 +11938,9 @@ static void f_printf(typval_T *argvars, typval_T *rettv)
|
||||
fmt = (char *)get_tv_string_buf(&argvars[0], buf);
|
||||
len = vim_vsnprintf(NULL, 0, fmt, ap, argvars + 1);
|
||||
if (!did_emsg) {
|
||||
s = alloc(len + 1);
|
||||
if (s != NULL) {
|
||||
rettv->vval.v_string = s;
|
||||
(void)vim_vsnprintf((char *)s, len + 1, fmt, ap, argvars + 1);
|
||||
}
|
||||
char *s = xmalloc(len + 1);
|
||||
rettv->vval.v_string = (char_u *)s;
|
||||
(void)vim_vsnprintf(s, len + 1, fmt, ap, argvars + 1);
|
||||
}
|
||||
did_emsg |= saved_did_emsg;
|
||||
}
|
||||
@ -12173,13 +12138,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv)
|
||||
long growmin = (long)((p - start) * 2 + prevlen);
|
||||
prevsize = grow50pc > growmin ? grow50pc : growmin;
|
||||
}
|
||||
newprev = prev == NULL ? alloc(prevsize)
|
||||
: xrealloc(prev, prevsize);
|
||||
if (newprev == NULL) {
|
||||
do_outofmem_msg((long_u)prevsize);
|
||||
failed = TRUE;
|
||||
break;
|
||||
}
|
||||
newprev = (prev == NULL) ? xmalloc(prevsize) : xrealloc(prev, prevsize);
|
||||
prev = newprev;
|
||||
}
|
||||
/* Add the line part to end of "prev". */
|
||||
@ -12417,10 +12376,6 @@ static void f_repeat(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
char_u *p;
|
||||
int n;
|
||||
int slen;
|
||||
int len;
|
||||
char_u *r;
|
||||
int i;
|
||||
|
||||
n = get_tv_number(&argvars[1]);
|
||||
if (argvars[0].v_type == VAR_LIST) {
|
||||
@ -12438,17 +12393,15 @@ static void f_repeat(typval_T *argvars, typval_T *rettv)
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
|
||||
slen = (int)STRLEN(p);
|
||||
len = slen * n;
|
||||
int slen = (int)STRLEN(p);
|
||||
int len = slen * n;
|
||||
if (len <= 0)
|
||||
return;
|
||||
|
||||
r = alloc(len + 1);
|
||||
if (r != NULL) {
|
||||
for (i = 0; i < n; i++)
|
||||
memmove(r + i * slen, p, (size_t)slen);
|
||||
r[len] = NUL;
|
||||
}
|
||||
char_u *r = xmalloc(len + 1);
|
||||
for (int i = 0; i < n; i++)
|
||||
memmove(r + i * slen, p, (size_t)slen);
|
||||
r[len] = NUL;
|
||||
|
||||
rettv->vval.v_string = r;
|
||||
}
|
||||
@ -12506,9 +12459,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
|
||||
q[-1] = NUL;
|
||||
}
|
||||
|
||||
buf = alloc(MAXPATHL + 1);
|
||||
if (buf == NULL)
|
||||
goto fail;
|
||||
buf = xmallocz(MAXPATHL);
|
||||
|
||||
for (;; ) {
|
||||
for (;; ) {
|
||||
@ -12554,13 +12505,11 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
if (q > p && !path_is_absolute_path(buf)) {
|
||||
/* symlink is relative to directory of argument */
|
||||
cpy = alloc((unsigned)(STRLEN(p) + STRLEN(buf) + 1));
|
||||
if (cpy != NULL) {
|
||||
STRCPY(cpy, p);
|
||||
STRCPY(path_tail(cpy), buf);
|
||||
free(p);
|
||||
p = cpy;
|
||||
}
|
||||
cpy = xmalloc(STRLEN(p) + STRLEN(buf) + 1);
|
||||
STRCPY(cpy, p);
|
||||
STRCPY(path_tail(cpy), buf);
|
||||
free(p);
|
||||
p = cpy;
|
||||
} else {
|
||||
free(p);
|
||||
p = vim_strsave(buf);
|
||||
@ -13067,10 +13016,8 @@ do_searchpair (
|
||||
|
||||
/* 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) + 15));
|
||||
pat3 = alloc((unsigned)(STRLEN(spat) + STRLEN(mpat) + STRLEN(epat) + 23));
|
||||
if (pat2 == NULL || pat3 == NULL)
|
||||
goto theend;
|
||||
pat2 = xmalloc(STRLEN(spat) + STRLEN(epat) + 15);
|
||||
pat3 = xmalloc(STRLEN(spat) + STRLEN(mpat) + STRLEN(epat) + 23);
|
||||
sprintf((char *)pat2, "\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat);
|
||||
if (*mpat == NUL)
|
||||
STRCPY(pat3, pat2);
|
||||
@ -13161,7 +13108,6 @@ do_searchpair (
|
||||
if ((flags & SP_NOMOVE) || retval == 0)
|
||||
curwin->w_cursor = save_cursor;
|
||||
|
||||
theend:
|
||||
free(pat2);
|
||||
free(pat3);
|
||||
if (p_cpo == empty_option)
|
||||
@ -13245,13 +13191,11 @@ static void f_setbufvar(typval_T *argvars, typval_T *rettv)
|
||||
if (!error && strval != NULL)
|
||||
set_option_value(varname, numval, strval, OPT_LOCAL);
|
||||
} else {
|
||||
bufvarname = alloc((unsigned)STRLEN(varname) + 3);
|
||||
if (bufvarname != NULL) {
|
||||
STRCPY(bufvarname, "b:");
|
||||
STRCPY(bufvarname + 2, varname);
|
||||
set_var(bufvarname, varp, TRUE);
|
||||
free(bufvarname);
|
||||
}
|
||||
bufvarname = xmalloc(STRLEN(varname) + 3);
|
||||
STRCPY(bufvarname, "b:");
|
||||
STRCPY(bufvarname + 2, varname);
|
||||
set_var(bufvarname, varp, TRUE);
|
||||
free(bufvarname);
|
||||
}
|
||||
|
||||
/* reset notion of buffer */
|
||||
@ -13557,13 +13501,11 @@ static void f_settabvar(typval_T *argvars, typval_T *rettv)
|
||||
save_curtab = curtab;
|
||||
goto_tabpage_tp(tp, FALSE, FALSE);
|
||||
|
||||
tabvarname = alloc((unsigned)STRLEN(varname) + 3);
|
||||
if (tabvarname != NULL) {
|
||||
STRCPY(tabvarname, "t:");
|
||||
STRCPY(tabvarname + 2, varname);
|
||||
set_var(tabvarname, varp, TRUE);
|
||||
free(tabvarname);
|
||||
}
|
||||
tabvarname = xmalloc(STRLEN(varname) + 3);
|
||||
STRCPY(tabvarname, "t:");
|
||||
STRCPY(tabvarname + 2, varname);
|
||||
set_var(tabvarname, varp, TRUE);
|
||||
free(tabvarname);
|
||||
|
||||
/* Restore current tabpage */
|
||||
if (valid_tabpage(save_curtab))
|
||||
@ -13627,13 +13569,11 @@ static void setwinvar(typval_T *argvars, typval_T *rettv, int off)
|
||||
if (!error && strval != NULL)
|
||||
set_option_value(varname, numval, strval, OPT_LOCAL);
|
||||
} else {
|
||||
winvarname = alloc((unsigned)STRLEN(varname) + 3);
|
||||
if (winvarname != NULL) {
|
||||
STRCPY(winvarname, "w:");
|
||||
STRCPY(winvarname + 2, varname);
|
||||
set_var(winvarname, varp, TRUE);
|
||||
free(winvarname);
|
||||
}
|
||||
winvarname = xmalloc(STRLEN(varname) + 3);
|
||||
STRCPY(winvarname, "w:");
|
||||
STRCPY(winvarname + 2, varname);
|
||||
set_var(winvarname, varp, TRUE);
|
||||
free(winvarname);
|
||||
}
|
||||
|
||||
restore_win(save_curwin, save_curtab, TRUE);
|
||||
@ -14828,7 +14768,7 @@ static void f_tagfiles(typval_T *argvars, typval_T *rettv)
|
||||
tagname_T tn;
|
||||
|
||||
rettv_list_alloc(rettv);
|
||||
fname = alloc(MAXPATHL);
|
||||
fname = xmalloc(MAXPATHL);
|
||||
|
||||
int first = TRUE;
|
||||
while (get_tagfname(&tn, first, fname) == OK) {
|
||||
@ -15767,13 +15707,11 @@ static char_u *make_expanded_name(char_u *in_start, char_u *expr_start, char_u *
|
||||
|
||||
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));
|
||||
if (retval != NULL) {
|
||||
STRCPY(retval, in_start);
|
||||
STRCAT(retval, temp_result);
|
||||
STRCAT(retval, expr_end + 1);
|
||||
}
|
||||
retval = xmalloc(STRLEN(temp_result) + (expr_start - in_start)
|
||||
+ (in_end - expr_end) + 1);
|
||||
STRCPY(retval, in_start);
|
||||
STRCAT(retval, temp_result);
|
||||
STRCAT(retval, expr_end + 1);
|
||||
}
|
||||
free(temp_result);
|
||||
|
||||
@ -15964,7 +15902,6 @@ char_u *set_cmdarg(exarg_T *eap, char_u *oldarg)
|
||||
{
|
||||
char_u *oldval;
|
||||
char_u *newval;
|
||||
unsigned len;
|
||||
|
||||
oldval = vimvars[VV_CMDARG].vv_str;
|
||||
if (eap == NULL) {
|
||||
@ -15973,26 +15910,23 @@ char_u *set_cmdarg(exarg_T *eap, char_u *oldarg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t len = 0;
|
||||
if (eap->force_bin == FORCE_BIN)
|
||||
len = 6;
|
||||
else if (eap->force_bin == FORCE_NOBIN)
|
||||
len = 8;
|
||||
else
|
||||
len = 0;
|
||||
|
||||
if (eap->read_edit)
|
||||
len += 7;
|
||||
|
||||
if (eap->force_ff != 0)
|
||||
len += (unsigned)STRLEN(eap->cmd + eap->force_ff) + 6;
|
||||
len += STRLEN(eap->cmd + eap->force_ff) + 6;
|
||||
if (eap->force_enc != 0)
|
||||
len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7;
|
||||
len += STRLEN(eap->cmd + eap->force_enc) + 7;
|
||||
if (eap->bad_char != 0)
|
||||
len += 7 + 4; /* " ++bad=" + "keep" or "drop" */
|
||||
|
||||
newval = alloc(len + 1);
|
||||
if (newval == NULL)
|
||||
return NULL;
|
||||
newval = xmalloc(len + 1);
|
||||
|
||||
if (eap->force_bin == FORCE_BIN)
|
||||
sprintf((char *)newval, " ++bin");
|
||||
@ -16747,10 +16681,7 @@ set_var (
|
||||
if (!valid_varname(varname))
|
||||
return;
|
||||
|
||||
v = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T)
|
||||
+ STRLEN(varname)));
|
||||
if (v == NULL)
|
||||
return;
|
||||
v = xmalloc(sizeof(dictitem_T) + STRLEN(varname));
|
||||
STRCPY(v->di_key, varname);
|
||||
if (hash_add(ht, DI2HIKEY(v)) == FAIL) {
|
||||
free(v);
|
||||
@ -17697,9 +17628,7 @@ void ex_function(exarg_T *eap)
|
||||
}
|
||||
}
|
||||
|
||||
fp = (ufunc_T *)alloc((unsigned)(sizeof(ufunc_T) + STRLEN(name)));
|
||||
if (fp == NULL)
|
||||
goto erret;
|
||||
fp = xmalloc(sizeof(ufunc_T) + STRLEN(name));
|
||||
|
||||
if (fudi.fd_dict != NULL) {
|
||||
if (fudi.fd_di == NULL) {
|
||||
@ -17927,18 +17856,16 @@ trans_function_name (
|
||||
}
|
||||
}
|
||||
|
||||
name = alloc((unsigned)(len + lead + 1));
|
||||
if (name != NULL) {
|
||||
if (lead > 0) {
|
||||
name[0] = K_SPECIAL;
|
||||
name[1] = KS_EXTRA;
|
||||
name[2] = (int)KE_SNR;
|
||||
if (lead > 3) /* If it's "<SID>" */
|
||||
STRCPY(name + 3, sid_buf);
|
||||
}
|
||||
memmove(name + lead, lv.ll_name, (size_t)len);
|
||||
name[lead + len] = NUL;
|
||||
name = xmalloc(len + lead + 1);
|
||||
if (lead > 0){
|
||||
name[0] = K_SPECIAL;
|
||||
name[1] = KS_EXTRA;
|
||||
name[2] = (int)KE_SNR;
|
||||
if (lead > 3) /* If it's "<SID>" */
|
||||
STRCPY(name + 3, sid_buf);
|
||||
}
|
||||
memmove(name + lead, lv.ll_name, (size_t)len);
|
||||
name[lead + len] = NUL;
|
||||
*pp = end;
|
||||
|
||||
theend:
|
||||
@ -18148,7 +18075,7 @@ void func_dump_profile(FILE *fd)
|
||||
if (todo == 0)
|
||||
return; /* nothing to dump */
|
||||
|
||||
sorttab = (ufunc_T **)alloc((unsigned)(sizeof(ufunc_T) * todo));
|
||||
sorttab = xmalloc(sizeof(ufunc_T) * todo);
|
||||
|
||||
for (hi = func_hashtab.ht_array; todo > 0; ++hi) {
|
||||
if (!HASHITEM_EMPTY(hi)) {
|
||||
@ -18326,9 +18253,7 @@ static char_u *autoload_name(char_u *name)
|
||||
char_u *scriptname;
|
||||
|
||||
/* Get the script file name: replace '#' with '/', append ".vim". */
|
||||
scriptname = alloc((unsigned)(STRLEN(name) + 14));
|
||||
if (scriptname == NULL)
|
||||
return FALSE;
|
||||
scriptname = xmalloc(STRLEN(name) + 14);
|
||||
STRCPY(scriptname, "autoload/");
|
||||
STRCAT(scriptname, name);
|
||||
*vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL;
|
||||
@ -18543,7 +18468,7 @@ call_user_func (
|
||||
|
||||
line_breakcheck(); /* check for CTRL-C hit */
|
||||
|
||||
fc = (funccall_T *)alloc(sizeof(funccall_T));
|
||||
fc = xmalloc(sizeof(funccall_T));
|
||||
fc->caller = current_funccal;
|
||||
current_funccal = fc;
|
||||
fc->func = fp;
|
||||
@ -18624,10 +18549,7 @@ call_user_func (
|
||||
v = &fc->fixvar[fixvar_idx++].var;
|
||||
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
|
||||
} else {
|
||||
v = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T)
|
||||
+ STRLEN(name)));
|
||||
if (v == NULL)
|
||||
break;
|
||||
v = xmalloc(sizeof(dictitem_T) + STRLEN(name));
|
||||
v->di_flags = DI_FLAGS_RO;
|
||||
}
|
||||
STRCPY(v->di_key, name);
|
||||
@ -18650,10 +18572,9 @@ call_user_func (
|
||||
save_sourcing_name = sourcing_name;
|
||||
save_sourcing_lnum = sourcing_lnum;
|
||||
sourcing_lnum = 1;
|
||||
sourcing_name = alloc((unsigned)((save_sourcing_name == NULL ? 0
|
||||
: STRLEN(save_sourcing_name)) +
|
||||
STRLEN(fp->uf_name) + 13));
|
||||
if (sourcing_name != NULL) {
|
||||
sourcing_name = xmalloc((save_sourcing_name == NULL ? 0 : STRLEN(save_sourcing_name))
|
||||
+ STRLEN(fp->uf_name) + 13);
|
||||
{
|
||||
if (save_sourcing_name != NULL
|
||||
&& STRNCMP(save_sourcing_name, "function ", 9) == 0)
|
||||
sprintf((char *)sourcing_name, "%s..", save_sourcing_name);
|
||||
@ -19612,19 +19533,21 @@ repeat:
|
||||
s = p + 1;
|
||||
/* find end of substitution */
|
||||
p = vim_strchr(s, sep);
|
||||
sub = vim_strnsave(s, (int)(p - s));
|
||||
str = vim_strnsave(*fnamep, *fnamelen);
|
||||
*usedlen = (int)(p + 1 - src);
|
||||
s = do_string_sub(str, pat, sub, flags);
|
||||
if (s != NULL) {
|
||||
*fnamep = s;
|
||||
*fnamelen = (int)STRLEN(s);
|
||||
free(*bufp);
|
||||
*bufp = s;
|
||||
didit = TRUE;
|
||||
if (p != NULL) {
|
||||
sub = vim_strnsave(s, (int)(p - s));
|
||||
str = vim_strnsave(*fnamep, *fnamelen);
|
||||
*usedlen = (int)(p + 1 - src);
|
||||
s = do_string_sub(str, pat, sub, flags);
|
||||
if (s != NULL) {
|
||||
*fnamep = s;
|
||||
*fnamelen = (int)STRLEN(s);
|
||||
free(*bufp);
|
||||
*bufp = s;
|
||||
didit = TRUE;
|
||||
}
|
||||
free(sub);
|
||||
free(str);
|
||||
}
|
||||
free(sub);
|
||||
free(str);
|
||||
free(pat);
|
||||
}
|
||||
}
|
||||
|
@ -244,11 +244,8 @@ int cause_errthrow(char_u *mesg, int severe, int *ignore)
|
||||
while (*plist != NULL)
|
||||
plist = &(*plist)->next;
|
||||
|
||||
elem = (struct msglist *)alloc((unsigned)sizeof(struct msglist));
|
||||
if (elem == NULL) {
|
||||
suppress_errthrow = TRUE;
|
||||
EMSG(_(e_outofmem));
|
||||
} else {
|
||||
elem = xmalloc(sizeof(struct msglist));
|
||||
{
|
||||
elem->msg = vim_strsave(mesg);
|
||||
{
|
||||
elem->next = NULL;
|
||||
@ -469,9 +466,7 @@ static int throw_exception(void *value, int type, char_u *cmdname)
|
||||
}
|
||||
}
|
||||
|
||||
excp = (except_T *)alloc((unsigned)sizeof(except_T));
|
||||
if (excp == NULL)
|
||||
goto nomem;
|
||||
excp = xmalloc(sizeof(except_T));
|
||||
|
||||
if (type == ET_ERROR)
|
||||
/* Store the original message and prefix the exception value with
|
||||
@ -1289,18 +1284,12 @@ void ex_try(exarg_T *eap)
|
||||
* to save the value.
|
||||
*/
|
||||
if (emsg_silent) {
|
||||
eslist_T *elem;
|
||||
|
||||
elem = (eslist_T *)alloc((unsigned)sizeof(struct eslist_elem));
|
||||
if (elem == NULL)
|
||||
EMSG(_(e_outofmem));
|
||||
else {
|
||||
elem->saved_emsg_silent = emsg_silent;
|
||||
elem->next = cstack->cs_emsg_silent_list;
|
||||
cstack->cs_emsg_silent_list = elem;
|
||||
cstack->cs_flags[cstack->cs_idx] |= CSF_SILENT;
|
||||
emsg_silent = 0;
|
||||
}
|
||||
eslist_T *elem = xmalloc(sizeof(struct eslist_elem));
|
||||
elem->saved_emsg_silent = emsg_silent;
|
||||
elem->next = cstack->cs_emsg_silent_list;
|
||||
cstack->cs_emsg_silent_list = elem;
|
||||
cstack->cs_flags[cstack->cs_idx] |= CSF_SILENT;
|
||||
emsg_silent = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1993,7 +1993,7 @@ static void alloc_cmdbuff(int len)
|
||||
else
|
||||
len += 20;
|
||||
|
||||
ccline.cmdbuff = alloc(len); /* caller should check for out-of-memory */
|
||||
ccline.cmdbuff = xmalloc(len); /* caller should check for out-of-memory */
|
||||
ccline.cmdbufflen = len;
|
||||
}
|
||||
|
||||
@ -2081,9 +2081,7 @@ static void draw_cmdline(int start, int len)
|
||||
* alloc()/free() calls. */
|
||||
free(arshape_buf);
|
||||
buflen = len * 2 + 2;
|
||||
arshape_buf = alloc(buflen);
|
||||
if (arshape_buf == NULL)
|
||||
return; /* out of memory */
|
||||
arshape_buf = xmalloc(buflen);
|
||||
}
|
||||
|
||||
if (utf_iscomposing(utf_ptr2char(ccline.cmdbuff + start))) {
|
||||
@ -2347,15 +2345,11 @@ static void restore_cmdline(struct cmdline_info *ccp)
|
||||
/*
|
||||
* Save the command line into allocated memory. Returns a pointer to be
|
||||
* passed to restore_cmdline_alloc() later.
|
||||
* Returns NULL when failed.
|
||||
*/
|
||||
char_u *save_cmdline_alloc(void)
|
||||
{
|
||||
struct cmdline_info *p;
|
||||
|
||||
p = (struct cmdline_info *)alloc((unsigned)sizeof(struct cmdline_info));
|
||||
if (p != NULL)
|
||||
save_cmdline(p);
|
||||
struct cmdline_info *p = xmalloc(sizeof(struct cmdline_info));
|
||||
save_cmdline(p);
|
||||
return (char_u *)p;
|
||||
}
|
||||
|
||||
@ -3103,15 +3097,11 @@ char_u *vim_strsave_fnameescape(char_u *fname, int shell)
|
||||
*/
|
||||
static void escape_fname(char_u **pp)
|
||||
{
|
||||
char_u *p;
|
||||
|
||||
p = alloc((unsigned)(STRLEN(*pp) + 2));
|
||||
if (p != NULL) {
|
||||
p[0] = '\\';
|
||||
STRCPY(p + 1, *pp);
|
||||
free(*pp);
|
||||
*pp = p;
|
||||
}
|
||||
char_u *p = xmalloc(STRLEN(*pp) + 2);
|
||||
p[0] = '\\';
|
||||
STRCPY(p + 1, *pp);
|
||||
free(*pp);
|
||||
*pp = p;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3402,8 +3392,8 @@ addstar (
|
||||
|| context == EXPAND_USER_LIST) && fname[i] == '\\')
|
||||
new_len++; /* '\' becomes "\\" */
|
||||
}
|
||||
retval = alloc(new_len);
|
||||
if (retval != NULL) {
|
||||
retval = xmalloc(new_len);
|
||||
{
|
||||
retval[0] = '^';
|
||||
j = 1;
|
||||
for (i = 0; i < len; i++, j++) {
|
||||
@ -3436,7 +3426,7 @@ addstar (
|
||||
}
|
||||
}
|
||||
} else {
|
||||
retval = alloc(len + 4);
|
||||
retval = xmalloc(len + 4);
|
||||
if (retval != NULL) {
|
||||
vim_strncpy(retval, fname, len);
|
||||
|
||||
@ -3830,7 +3820,7 @@ ExpandFromContext (
|
||||
* obtain strings, one by one. The strings are matched against a regexp
|
||||
* program. Matching strings are copied into an array, which is returned.
|
||||
*
|
||||
* Returns OK when no problems encountered, FAIL for error (out of memory).
|
||||
* Returns OK when no problems encountered, FAIL for error.
|
||||
*/
|
||||
int ExpandGeneric(xp, regmatch, num_file, file, func, escaped)
|
||||
expand_T *xp;
|
||||
@ -3859,11 +3849,7 @@ int escaped;
|
||||
if (count == 0)
|
||||
return OK;
|
||||
*num_file = count;
|
||||
*file = (char_u **)alloc((unsigned)(count * sizeof(char_u *)));
|
||||
if (*file == NULL) {
|
||||
*file = (char_u **)"";
|
||||
return FAIL;
|
||||
}
|
||||
*file = (char_u **)xmalloc(count * sizeof(char_u *));
|
||||
|
||||
// copy the matching names into allocated memory
|
||||
count = 0;
|
||||
@ -3924,15 +3910,12 @@ expand_shellcmd (
|
||||
char_u *path;
|
||||
int mustfree = FALSE;
|
||||
garray_T ga;
|
||||
char_u *buf = alloc(MAXPATHL);
|
||||
char_u *buf = xmalloc(MAXPATHL);
|
||||
size_t l;
|
||||
char_u *s, *e;
|
||||
int flags = flagsarg;
|
||||
int ret;
|
||||
|
||||
if (buf == NULL)
|
||||
return FAIL;
|
||||
|
||||
/* for ":set path=" and ":set tags=" halve backslashes for escaped
|
||||
* space */
|
||||
pat = vim_strsave(filepat);
|
||||
@ -4156,11 +4139,7 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname
|
||||
ga_init(&ga, (int)sizeof(char *), 10);
|
||||
|
||||
for (i = 0; dirnames[i] != NULL; ++i) {
|
||||
s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 7));
|
||||
if (s == NULL) {
|
||||
ga_clear_strings(&ga);
|
||||
return FAIL;
|
||||
}
|
||||
s = xmalloc(STRLEN(dirnames[i]) + pat_len + 7);
|
||||
sprintf((char *)s, "%s/%s*.vim", dirnames[i], pat);
|
||||
matches = globpath(p_rtp, s, 0);
|
||||
free(s);
|
||||
@ -4207,7 +4186,6 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname
|
||||
char_u *globpath(char_u *path, char_u *file, int expand_options)
|
||||
{
|
||||
expand_T xpc;
|
||||
char_u *buf;
|
||||
garray_T ga;
|
||||
int i;
|
||||
int len;
|
||||
@ -4215,9 +4193,7 @@ char_u *globpath(char_u *path, char_u *file, int expand_options)
|
||||
char_u **p;
|
||||
char_u *cur = NULL;
|
||||
|
||||
buf = alloc(MAXPATHL);
|
||||
if (buf == NULL)
|
||||
return NULL;
|
||||
char_u *buf = xmalloc(MAXPATHL);
|
||||
|
||||
ExpandInit(&xpc);
|
||||
xpc.xp_context = EXPAND_FILES;
|
||||
|
@ -278,8 +278,7 @@ vim_findfile_init (
|
||||
if (search_ctx_arg != NULL)
|
||||
search_ctx = search_ctx_arg;
|
||||
else {
|
||||
search_ctx = (ff_search_ctx_T*)alloc((unsigned)sizeof(ff_search_ctx_T));
|
||||
memset(search_ctx, 0, sizeof(ff_search_ctx_T));
|
||||
search_ctx = xcalloc(1, sizeof(ff_search_ctx_T));
|
||||
}
|
||||
search_ctx->ffsc_find_what = find_what;
|
||||
search_ctx->ffsc_tagfile = tagfile;
|
||||
@ -305,7 +304,7 @@ vim_findfile_init (
|
||||
}
|
||||
|
||||
if (ff_expand_buffer == NULL) {
|
||||
ff_expand_buffer = (char_u*)alloc(MAXPATHL);
|
||||
ff_expand_buffer = xmalloc(MAXPATHL);
|
||||
}
|
||||
|
||||
/* Store information on starting dir now if path is relative.
|
||||
@ -370,8 +369,7 @@ vim_findfile_init (
|
||||
walker++;
|
||||
|
||||
dircount = 1;
|
||||
search_ctx->ffsc_stopdirs_v =
|
||||
(char_u **)alloc((unsigned)sizeof(char_u *));
|
||||
search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char_u *));
|
||||
|
||||
do {
|
||||
char_u *helper;
|
||||
@ -474,9 +472,8 @@ vim_findfile_init (
|
||||
STRCPY(ff_expand_buffer, search_ctx->ffsc_start_dir);
|
||||
add_pathsep(ff_expand_buffer);
|
||||
{
|
||||
int eb_len = (int)STRLEN(ff_expand_buffer);
|
||||
char_u *buf = alloc(eb_len
|
||||
+ (int)STRLEN(search_ctx->ffsc_fix_path) + 1);
|
||||
size_t eb_len = STRLEN(ff_expand_buffer);
|
||||
char_u *buf = xmalloc(eb_len + STRLEN(search_ctx->ffsc_fix_path) + 1);
|
||||
|
||||
STRCPY(buf, ff_expand_buffer);
|
||||
STRCPY(buf + eb_len, search_ctx->ffsc_fix_path);
|
||||
@ -498,9 +495,9 @@ vim_findfile_init (
|
||||
|
||||
if (search_ctx->ffsc_wc_path != NULL) {
|
||||
wc_path = vim_strsave(search_ctx->ffsc_wc_path);
|
||||
temp = alloc((int)(STRLEN(search_ctx->ffsc_wc_path)
|
||||
+ STRLEN(search_ctx->ffsc_fix_path + len)
|
||||
+ 1));
|
||||
temp = xmalloc(STRLEN(search_ctx->ffsc_wc_path)
|
||||
+ STRLEN(search_ctx->ffsc_fix_path + len)
|
||||
+ 1);
|
||||
}
|
||||
|
||||
if (temp == NULL || wc_path == NULL) {
|
||||
@ -610,8 +607,7 @@ char_u *vim_findfile(void *search_ctx_arg)
|
||||
* filepath is used as buffer for various actions and as the storage to
|
||||
* return a found filename.
|
||||
*/
|
||||
if ((file_path = alloc((int)MAXPATHL)) == NULL)
|
||||
return NULL;
|
||||
file_path = xmalloc(MAXPATHL);
|
||||
|
||||
/* store the end of the start dir -- needed for upward search */
|
||||
if (search_ctx->ffsc_start_dir != NULL)
|
||||
@ -763,12 +759,9 @@ char_u *vim_findfile(void *search_ctx_arg)
|
||||
* If the path is a URL don't try this.
|
||||
*/
|
||||
if (path_with_url(dirptrs[0])) {
|
||||
stackp->ffs_filearray = (char_u **)
|
||||
alloc((unsigned)sizeof(char *));
|
||||
if ((stackp->ffs_filearray[0] = vim_strsave(dirptrs[0])) != NULL)
|
||||
stackp->ffs_filearray_size = 1;
|
||||
else
|
||||
stackp->ffs_filearray_size = 0;
|
||||
stackp->ffs_filearray = (char_u **)xmalloc(sizeof(char *));
|
||||
stackp->ffs_filearray[0] = vim_strsave(dirptrs[0]);
|
||||
stackp->ffs_filearray_size = 1;
|
||||
} else
|
||||
/* Add EW_NOTWILD because the expanded path may contain
|
||||
* wildcard characters that are to be taken literally.
|
||||
@ -1053,7 +1046,7 @@ static ff_visited_list_hdr_T *ff_get_visited_list(char_u *filename, ff_visited_l
|
||||
/*
|
||||
* 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 = xmalloc(sizeof(*retptr));
|
||||
|
||||
retptr->ffvl_visited_list = NULL;
|
||||
retptr->ffvl_filename = vim_strsave(filename);
|
||||
@ -1139,8 +1132,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char_u *fname, char_u *
|
||||
/*
|
||||
* 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 = xmalloc(sizeof(ff_visited_T) + STRLEN(ff_expand_buffer));
|
||||
|
||||
if (!url) {
|
||||
vp->ffv_dev_valid = TRUE;
|
||||
@ -1495,7 +1487,7 @@ find_file_in_path_option (
|
||||
break;
|
||||
}
|
||||
|
||||
buf = alloc((int)(MAXPATHL));
|
||||
buf = xmalloc(MAXPATHL);
|
||||
|
||||
/* copy next path */
|
||||
buf[0] = 0;
|
||||
|
@ -3704,7 +3704,7 @@ restore_backup:
|
||||
"E513: write error, conversion failed (make 'fenc' empty to override)");
|
||||
else {
|
||||
errmsg_allocated = TRUE;
|
||||
errmsg = alloc(300);
|
||||
errmsg = xmalloc(300);
|
||||
vim_snprintf((char *)errmsg, 300,
|
||||
_("E513: write error, conversion failed in line %" PRId64
|
||||
" (make 'fenc' empty to override)"),
|
||||
@ -4649,7 +4649,7 @@ modname (
|
||||
* (we need the full path in case :cd is used).
|
||||
*/
|
||||
if (fname == NULL || *fname == NUL) {
|
||||
retval = alloc((unsigned)(MAXPATHL + extlen + 3));
|
||||
retval = xmalloc(MAXPATHL + extlen + 3);
|
||||
if (os_dirname(retval, MAXPATHL) == FAIL ||
|
||||
(fnamelen = (int)STRLEN(retval)) == 0) {
|
||||
free(retval);
|
||||
@ -4662,7 +4662,7 @@ modname (
|
||||
prepend_dot = FALSE; /* nothing to prepend a dot to */
|
||||
} else {
|
||||
fnamelen = (int)STRLEN(fname);
|
||||
retval = alloc((unsigned)(fnamelen + extlen + 3));
|
||||
retval = xmalloc(fnamelen + extlen + 3);
|
||||
STRCPY(retval, fname);
|
||||
}
|
||||
|
||||
@ -5212,8 +5212,7 @@ buf_check_timestamp (
|
||||
if (path != NULL) {
|
||||
if (!helpmesg)
|
||||
mesg2 = "";
|
||||
tbuf = alloc((unsigned)(STRLEN(path) + STRLEN(mesg)
|
||||
+ STRLEN(mesg2) + 2));
|
||||
tbuf = xmalloc(STRLEN(path) + STRLEN(mesg) + STRLEN(mesg2) + 2);
|
||||
sprintf((char *)tbuf, mesg, path);
|
||||
/* Set warningmsg here, before the unimportant and output-specific
|
||||
* mesg2 has been appended. */
|
||||
@ -6574,7 +6573,7 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd,
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
ap = (AutoPat *)alloc((unsigned)sizeof(AutoPat));
|
||||
ap = xmalloc(sizeof(AutoPat));
|
||||
ap->pat = vim_strnsave(pat, patlen);
|
||||
ap->patlen = patlen;
|
||||
|
||||
@ -6611,7 +6610,7 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd,
|
||||
prev_ac = &(ap->cmds);
|
||||
while ((ac = *prev_ac) != NULL)
|
||||
prev_ac = &ac->next;
|
||||
ac = (AutoCmd *)alloc((unsigned)sizeof(AutoCmd));
|
||||
ac = xmalloc(sizeof(AutoCmd));
|
||||
ac->cmd = vim_strsave(cmd);
|
||||
ac->scriptID = current_SID;
|
||||
ac->next = NULL;
|
||||
@ -7420,8 +7419,7 @@ auto_next_pat (
|
||||
: ap->buflocal_nr == apc->arg_bufnr) {
|
||||
name = event_nr2name(apc->event);
|
||||
s = _("%s Auto commands for \"%s\"");
|
||||
sourcing_name = alloc((unsigned)(STRLEN(s)
|
||||
+ STRLEN(name) + ap->patlen + 1));
|
||||
sourcing_name = xmalloc(STRLEN(s) + STRLEN(name) + ap->patlen + 1);
|
||||
sprintf((char *)sourcing_name, s,
|
||||
(char *)name, (char *)ap->pat);
|
||||
if (p_verbose >= 8) {
|
||||
|
@ -1610,7 +1610,7 @@ static void foldAddMarker(linenr_T lnum, char_u *marker, int markerlen)
|
||||
line_len = (int)STRLEN(line);
|
||||
|
||||
if (u_save(lnum - 1, lnum + 1) == OK) {
|
||||
newline = alloc((unsigned)(line_len + markerlen + STRLEN(cms) + 1));
|
||||
newline = xmalloc(line_len + markerlen + STRLEN(cms) + 1);
|
||||
STRCPY(newline, line);
|
||||
if (p == NULL)
|
||||
vim_strncpy(newline + line_len, marker, markerlen);
|
||||
@ -1681,7 +1681,7 @@ static void foldDelMarker(linenr_T lnum, char_u *marker, int markerlen)
|
||||
}
|
||||
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 = xmalloc(STRLEN(line) - len + 1);
|
||||
STRNCPY(newline, line, p - line);
|
||||
STRCPY(newline + (p - line), p + len);
|
||||
ml_replace(lnum, newline, FALSE);
|
||||
|
@ -891,14 +891,8 @@ int ins_typebuf(char_u *str, int noremap, int offset, int nottyped, int silent)
|
||||
setcursor();
|
||||
return FAIL;
|
||||
}
|
||||
s1 = alloc(newlen);
|
||||
if (s1 == NULL) /* out of memory */
|
||||
return FAIL;
|
||||
s2 = alloc(newlen);
|
||||
if (s2 == NULL) { /* out of memory */
|
||||
free(s1);
|
||||
return FAIL;
|
||||
}
|
||||
s1 = xmalloc(newlen);
|
||||
s2 = xmalloc(newlen);
|
||||
typebuf.tb_buflen = newlen;
|
||||
|
||||
/* copy the old chars, before the insertion point */
|
||||
@ -1147,16 +1141,11 @@ static void may_sync_undo(void)
|
||||
|
||||
/*
|
||||
* Make "typebuf" empty and allocate new buffers.
|
||||
* Returns FAIL when out of memory.
|
||||
*/
|
||||
int alloc_typebuf(void)
|
||||
{
|
||||
typebuf.tb_buf = alloc(TYPELEN_INIT);
|
||||
typebuf.tb_noremap = alloc(TYPELEN_INIT);
|
||||
if (typebuf.tb_buf == NULL || typebuf.tb_noremap == NULL) {
|
||||
free_typebuf();
|
||||
return FAIL;
|
||||
}
|
||||
typebuf.tb_buf = xmalloc(TYPELEN_INIT);
|
||||
typebuf.tb_noremap = xmalloc(TYPELEN_INIT);
|
||||
typebuf.tb_buflen = TYPELEN_INIT;
|
||||
typebuf.tb_off = 0;
|
||||
typebuf.tb_len = 0;
|
||||
@ -3038,11 +3027,7 @@ do_map (
|
||||
/*
|
||||
* Get here when adding a new entry to the maphash[] list or abbrlist.
|
||||
*/
|
||||
mp = (mapblock_T *)alloc((unsigned)sizeof(mapblock_T));
|
||||
if (mp == NULL) {
|
||||
retval = 4; /* no mem */
|
||||
goto theend;
|
||||
}
|
||||
mp = xmalloc(sizeof(mapblock_T));
|
||||
|
||||
/* If CTRL-C has been mapped, don't always use it for Interrupting */
|
||||
if (*keys == Ctrl_C)
|
||||
@ -3548,9 +3533,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char_u ***file)
|
||||
break; /* for (round) */
|
||||
|
||||
if (round == 1) {
|
||||
*file = (char_u **)alloc((unsigned)(count * sizeof(char_u *)));
|
||||
if (*file == NULL)
|
||||
return FAIL;
|
||||
*file = (char_u **)xmalloc(count * sizeof(char_u *));
|
||||
}
|
||||
} /* for (round) */
|
||||
|
||||
@ -3813,7 +3796,7 @@ char_u *vim_strsave_escape_csi(char_u *p)
|
||||
char_u *s, *d;
|
||||
|
||||
/* Need a buffer to hold up to three times as much. */
|
||||
res = alloc((unsigned)(STRLEN(p) * 3) + 1);
|
||||
res = xmalloc(STRLEN(p) * 3 + 1);
|
||||
d = res;
|
||||
for (s = p; *s != NUL; ) {
|
||||
if (s[0] == K_SPECIAL && s[1] != NUL && s[2] != NUL) {
|
||||
|
@ -347,18 +347,7 @@ static int hash_may_resize(hashtab_T *ht, int minitems)
|
||||
}
|
||||
} else {
|
||||
// Allocate an array.
|
||||
newarray = (hashitem_T *)alloc((unsigned)(sizeof(hashitem_T) * newsize));
|
||||
|
||||
if (newarray == NULL) {
|
||||
// Out of memory. When there are NULL items still return OK.
|
||||
// Otherwise set ht_error, because lookup may result in a hang if
|
||||
// we add another item.
|
||||
if (ht->ht_filled < ht->ht_mask) {
|
||||
return OK;
|
||||
}
|
||||
ht->ht_error = TRUE;
|
||||
return FAIL;
|
||||
}
|
||||
newarray = xmalloc(sizeof(hashitem_T) * newsize);
|
||||
oldarray = ht->ht_array;
|
||||
}
|
||||
memset(newarray, 0, (size_t)(sizeof(hashitem_T) * newsize));
|
||||
|
@ -459,7 +459,7 @@ static int cs_add(exarg_T *eap)
|
||||
static void 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 = xmalloc(strlen(stat_emsg) + MAXPATHL + 10);
|
||||
|
||||
(void)sprintf(buf, stat_emsg, fname, errno);
|
||||
(void)EMSG(buf);
|
||||
@ -490,7 +490,7 @@ cs_add_common (
|
||||
char_u *fbuf = NULL;
|
||||
|
||||
/* get the filename (arg1), expand it, and try to stat it */
|
||||
fname = (char *)alloc(MAXPATHL + 1);
|
||||
fname = xmalloc(MAXPATHL + 1);
|
||||
|
||||
expand_env((char_u *)arg1, (char_u *)fname, MAXPATHL);
|
||||
len = (int)STRLEN(fname);
|
||||
@ -512,7 +512,7 @@ staterr:
|
||||
|
||||
// get the prepend path (arg2), expand it, and see if it exists
|
||||
if (arg2 != NULL) {
|
||||
ppath = (char *)alloc(MAXPATHL + 1);
|
||||
ppath = xmalloc(MAXPATHL + 1);
|
||||
expand_env((char_u *)arg2, (char_u *)ppath, MAXPATHL);
|
||||
if (!os_file_exists((char_u *)ppath))
|
||||
goto staterr;
|
||||
@ -520,7 +520,7 @@ staterr:
|
||||
|
||||
/* if filename is a directory, append the cscope database name to it */
|
||||
if ((file_info.stat.st_mode & S_IFMT) == S_IFDIR) {
|
||||
fname2 = (char *)alloc((unsigned)(strlen(CSCOPE_DBFILE) + strlen(fname) + 2));
|
||||
fname2 = (char *)xmalloc(strlen(CSCOPE_DBFILE) + strlen(fname) + 2);
|
||||
|
||||
while (fname[strlen(fname)-1] == '/'
|
||||
) {
|
||||
@ -625,10 +625,9 @@ cs_reading_emsg (
|
||||
static int cs_cnt_matches(int idx)
|
||||
{
|
||||
char *stok;
|
||||
char *buf;
|
||||
int nlines;
|
||||
|
||||
buf = (char *)alloc(CSREAD_BUFSIZE);
|
||||
char *buf = xmalloc(CSREAD_BUFSIZE);
|
||||
for (;; ) {
|
||||
if (!fgets(buf, CSREAD_BUFSIZE, csinfo[idx].fr_fp)) {
|
||||
if (feof(csinfo[idx].fr_fp))
|
||||
@ -721,7 +720,7 @@ static char *cs_create_cmd(char *csoption, char *pattern)
|
||||
while (vim_iswhite(*pat))
|
||||
++pat;
|
||||
|
||||
cmd = (char *)alloc((unsigned)(strlen(pat) + 2));
|
||||
cmd = xmalloc(strlen(pat) + 2);
|
||||
|
||||
(void)sprintf(cmd, "%d%s", search, pat);
|
||||
|
||||
@ -801,14 +800,14 @@ err_closing:
|
||||
}
|
||||
#endif
|
||||
/* expand the cscope exec for env var's */
|
||||
prog = (char *)alloc(MAXPATHL + 1);
|
||||
prog = xmalloc(MAXPATHL + 1);
|
||||
expand_env((char_u *)p_csprg, (char_u *)prog, MAXPATHL);
|
||||
|
||||
/* alloc space to hold the cscope command */
|
||||
len = (int)(strlen(prog) + strlen(csinfo[i].fname) + 32);
|
||||
if (csinfo[i].ppath) {
|
||||
/* expand the prepend path for env var's */
|
||||
ppath = (char *)alloc(MAXPATHL + 1);
|
||||
ppath = xmalloc(MAXPATHL + 1);
|
||||
expand_env((char_u *)csinfo[i].ppath, (char_u *)ppath, MAXPATHL);
|
||||
|
||||
len += (int)strlen(ppath);
|
||||
@ -817,7 +816,7 @@ err_closing:
|
||||
if (csinfo[i].flags)
|
||||
len += (int)strlen(csinfo[i].flags);
|
||||
|
||||
cmd = (char *)alloc(len);
|
||||
cmd = xmalloc(len);
|
||||
|
||||
/* run the cscope command; is there execl for non-unix systems? */
|
||||
#if defined(UNIX)
|
||||
@ -1009,7 +1008,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int us
|
||||
if (strchr(CSQF_FLAGS, *qfpos) == NULL) {
|
||||
char *nf = _("E469: invalid cscopequickfix flag %c for %c");
|
||||
/* strlen will be enough because we use chars */
|
||||
char *buf = (char *)alloc((unsigned)strlen(nf));
|
||||
char *buf = xmalloc(strlen(nf));
|
||||
|
||||
sprintf(buf, nf, *qfpos, *(qfpos-1));
|
||||
(void)EMSG(buf);
|
||||
@ -1030,7 +1029,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int us
|
||||
if (cmd == NULL)
|
||||
return FALSE;
|
||||
|
||||
nummatches = (int *)alloc(sizeof(int)*csinfo_size);
|
||||
nummatches = xmalloc(sizeof(int) * csinfo_size);
|
||||
|
||||
/* Send query to all open connections, then count the total number
|
||||
* of matches so we can alloc all in one swell foop. */
|
||||
@ -1064,7 +1063,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int us
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
buf = (char *)alloc((unsigned)(strlen(opt) + strlen(pat) + strlen(nf)));
|
||||
buf = xmalloc(strlen(opt) + strlen(pat) + strlen(nf));
|
||||
sprintf(buf, nf, opt, pat);
|
||||
(void)EMSG(buf);
|
||||
free(buf);
|
||||
@ -1249,18 +1248,18 @@ static int cs_insert_filelist(char *fname, char *ppath, char *flags,
|
||||
clear_csinfo(j);
|
||||
}
|
||||
|
||||
csinfo[i].fname = (char *)alloc((unsigned)strlen(fname)+1);
|
||||
csinfo[i].fname = xmalloc(strlen(fname) + 1);
|
||||
|
||||
(void)strcpy(csinfo[i].fname, (const char *)fname);
|
||||
|
||||
if (ppath != NULL) {
|
||||
csinfo[i].ppath = (char *)alloc((unsigned)strlen(ppath) + 1);
|
||||
csinfo[i].ppath = xmalloc(strlen(ppath) + 1);
|
||||
(void)strcpy(csinfo[i].ppath, (const char *)ppath);
|
||||
} else
|
||||
csinfo[i].ppath = NULL;
|
||||
|
||||
if (flags != NULL) {
|
||||
csinfo[i].flags = (char *)alloc((unsigned)strlen(flags) + 1);
|
||||
csinfo[i].flags = xmalloc(strlen(flags) + 1);
|
||||
(void)strcpy(csinfo[i].flags, (const char *)flags);
|
||||
} else
|
||||
csinfo[i].flags = NULL;
|
||||
@ -1553,13 +1552,12 @@ static char *cs_parse_results(int cnumber, char *buf, int bufsize, char **contex
|
||||
static void cs_file_results(FILE *f, int *nummatches_a)
|
||||
{
|
||||
int i, j;
|
||||
char *buf;
|
||||
char *search, *slno;
|
||||
char *fullname;
|
||||
char *cntx;
|
||||
char *context;
|
||||
|
||||
buf = (char *)alloc(CSREAD_BUFSIZE);
|
||||
char *buf = xmalloc(CSREAD_BUFSIZE);
|
||||
|
||||
for (i = 0; i < csinfo_size; i++) {
|
||||
if (nummatches_a[i] < 1)
|
||||
@ -1570,7 +1568,7 @@ static void cs_file_results(FILE *f, int *nummatches_a)
|
||||
&slno, &search)) == NULL)
|
||||
continue;
|
||||
|
||||
context = (char *)alloc((unsigned)strlen(cntx)+5);
|
||||
context = xmalloc(strlen(cntx) + 5);
|
||||
|
||||
if (strcmp(cntx, "<global>")==0)
|
||||
strcpy(context, "<<global>>");
|
||||
@ -1686,9 +1684,6 @@ static char *cs_pathcomponents(char *path)
|
||||
*/
|
||||
static void cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
|
||||
{
|
||||
char *buf = NULL;
|
||||
int bufsize = 0; /* Track available bufsize */
|
||||
int newsize = 0;
|
||||
char *ptag;
|
||||
char *fname, *lno, *extra, *tbuf;
|
||||
int i, idx, num;
|
||||
@ -1700,14 +1695,14 @@ static void cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
|
||||
|
||||
assert (num_matches > 0);
|
||||
|
||||
tbuf = (char *)alloc((unsigned)strlen(matches[0]) + 1);
|
||||
tbuf = xmalloc(strlen(matches[0]) + 1);
|
||||
|
||||
strcpy(tbuf, matches[0]);
|
||||
ptag = strtok(tbuf, "\t");
|
||||
|
||||
newsize = (int)(strlen(cstag_msg) + strlen(ptag));
|
||||
buf = (char *)alloc(newsize);
|
||||
bufsize = newsize;
|
||||
size_t newsize = strlen(cstag_msg) + strlen(ptag);
|
||||
char *buf = xmalloc(newsize);
|
||||
size_t bufsize = newsize; // Track available bufsize
|
||||
(void)sprintf(buf, cstag_msg, ptag);
|
||||
MSG_PUTS_ATTR(buf, hl_attr(HLF_T));
|
||||
|
||||
@ -1725,7 +1720,7 @@ static void cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
|
||||
* by parsing matches[i] on the fly and placing stuff into buf
|
||||
* directly, but that's too much of a hassle
|
||||
*/
|
||||
tbuf = (char *)alloc((unsigned)strlen(matches[idx]) + 1);
|
||||
tbuf = xmalloc(strlen(matches[idx]) + 1);
|
||||
(void)strcpy(tbuf, matches[idx]);
|
||||
|
||||
if (strtok(tbuf, (const char *)"\t") == NULL)
|
||||
@ -1739,9 +1734,9 @@ static void cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
|
||||
lno[strlen(lno)-2] = '\0'; /* ignore ;" at the end */
|
||||
|
||||
/* hopefully 'num' (num of matches) will be less than 10^16 */
|
||||
newsize = (int)(strlen(csfmt_str) + 16 + strlen(lno));
|
||||
newsize = strlen(csfmt_str) + 16 + strlen(lno);
|
||||
if (bufsize < newsize) {
|
||||
buf = (char *)xrealloc(buf, newsize);
|
||||
buf = xrealloc(buf, newsize);
|
||||
bufsize = newsize;
|
||||
}
|
||||
if (buf != NULL) {
|
||||
@ -1756,10 +1751,10 @@ static void cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
|
||||
context = cntxts[idx];
|
||||
else
|
||||
context = globalcntx;
|
||||
newsize = (int)(strlen(context) + strlen(cntxformat));
|
||||
newsize = strlen(context) + strlen(cntxformat);
|
||||
|
||||
if (bufsize < newsize) {
|
||||
buf = (char *)xrealloc(buf, newsize);
|
||||
buf = xrealloc(buf, newsize);
|
||||
bufsize = newsize;
|
||||
}
|
||||
if (buf != NULL) {
|
||||
@ -1819,9 +1814,11 @@ static int cs_read_prompt(int i)
|
||||
while ((ch = getc(csinfo[i].fr_fp)) != EOF && ch != CSCOPE_PROMPT[0])
|
||||
/* if there is room and char is printable */
|
||||
if (bufpos < maxlen - 1 && vim_isprintc(ch)) {
|
||||
if (buf == NULL) /* lazy buffer allocation */
|
||||
buf = (char *)alloc(maxlen);
|
||||
if (buf != NULL) {
|
||||
// lazy buffer allocation
|
||||
if (buf == NULL) {
|
||||
buf = xmalloc(maxlen);
|
||||
}
|
||||
{
|
||||
/* append character to the message */
|
||||
buf[bufpos++] = ch;
|
||||
buf[bufpos] = NUL;
|
||||
@ -2072,7 +2069,6 @@ static int cs_reset(exarg_T *eap)
|
||||
static char *cs_resolve_file(int i, char *name)
|
||||
{
|
||||
char *fullname;
|
||||
int len;
|
||||
char_u *csdir = NULL;
|
||||
|
||||
/*
|
||||
@ -2080,17 +2076,17 @@ static char *cs_resolve_file(int i, char *name)
|
||||
* Fullname is freed after cs_make_vim_style_matches, after it's been
|
||||
* copied into the tag buffer used by Vim.
|
||||
*/
|
||||
len = (int)(strlen(name) + 2);
|
||||
size_t len = strlen(name) + 2;
|
||||
if (csinfo[i].ppath != NULL)
|
||||
len += (int)strlen(csinfo[i].ppath);
|
||||
len += strlen(csinfo[i].ppath);
|
||||
else if (p_csre && csinfo[i].fname != NULL) {
|
||||
/* If 'cscoperelative' is set and ppath is not set, use cscope.out
|
||||
* path in path resolution. */
|
||||
csdir = alloc(MAXPATHL);
|
||||
csdir = xmalloc(MAXPATHL);
|
||||
vim_strncpy(csdir, (char_u *)csinfo[i].fname,
|
||||
path_tail((char_u *)csinfo[i].fname)
|
||||
- (char_u *)csinfo[i].fname);
|
||||
len += (int)STRLEN(csdir);
|
||||
len += STRLEN(csdir);
|
||||
}
|
||||
|
||||
/* Note/example: this won't work if the cscope output already starts
|
||||
|
@ -182,7 +182,7 @@ int set_indent(int size, int flags)
|
||||
// characters and allocate accordingly. We will fill the rest with spaces
|
||||
// after the if (!curbuf->b_p_et) below.
|
||||
if (orig_char_len != -1) {
|
||||
newline = alloc(orig_char_len + size - ind_done + line_len);
|
||||
newline = xmalloc(orig_char_len + size - ind_done + line_len);
|
||||
todo = size - ind_done;
|
||||
|
||||
// Set total length of indent in characters, which may have been
|
||||
@ -203,7 +203,7 @@ int set_indent(int size, int flags)
|
||||
}
|
||||
} else {
|
||||
todo = size;
|
||||
newline = alloc(ind_len + line_len);
|
||||
newline = xmalloc(ind_len + line_len);
|
||||
s = newline;
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ int copy_indent(int size, char_u *src)
|
||||
// Allocate memory for the result: the copied indent, new indent
|
||||
// and the rest of the line.
|
||||
line_len = (int)STRLEN(ml_get_curline()) + 1;
|
||||
line = alloc(ind_len + line_len);
|
||||
line = xmalloc(ind_len + line_len);
|
||||
p = line;
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ int cin_is_cinword(char_u *line)
|
||||
int len;
|
||||
|
||||
cinw_len = (int)STRLEN(curbuf->b_p_cinw) + 1;
|
||||
cinw_buf = alloc((unsigned)cinw_len);
|
||||
cinw_buf = xmalloc(cinw_len);
|
||||
line = skipwhite(line);
|
||||
for (cinw = curbuf->b_p_cinw; *cinw; ) {
|
||||
len = copy_option_part(&cinw, cinw_buf, cinw_len, ",");
|
||||
|
@ -1321,7 +1321,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
--argv;
|
||||
} else
|
||||
a = argv[0];
|
||||
p = alloc((unsigned)(STRLEN(a) + 4));
|
||||
p = xmalloc(STRLEN(a) + 4);
|
||||
sprintf((char *)p, "so %s", a);
|
||||
parmp->cmds_tofree[parmp->n_commands] = TRUE;
|
||||
parmp->commands[parmp->n_commands++] = p;
|
||||
@ -1469,7 +1469,7 @@ scripterror:
|
||||
/* If there is a "+123" or "-c" command, set v:swapcommand to the first
|
||||
* one. */
|
||||
if (parmp->n_commands > 0) {
|
||||
p = alloc((unsigned)STRLEN(parmp->commands[0]) + 3);
|
||||
p = xmalloc(STRLEN(parmp->commands[0]) + 3);
|
||||
sprintf((char *)p, ":%s\r", parmp->commands[0]);
|
||||
set_vim_var_string(VV_SWAPCOMMAND, p, -1);
|
||||
free(p);
|
||||
@ -1515,7 +1515,7 @@ static void init_startuptime(mparm_T *paramp)
|
||||
*/
|
||||
static void allocate_generic_buffers(void)
|
||||
{
|
||||
NameBuff = alloc(MAXPATHL);
|
||||
NameBuff = xmalloc(MAXPATHL);
|
||||
TIME_MSG("Allocated generic buffers");
|
||||
}
|
||||
|
||||
|
@ -1417,7 +1417,7 @@ void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags
|
||||
pos_T pos;
|
||||
list_T *list = NULL;
|
||||
|
||||
name_buf = alloc(LSIZE);
|
||||
name_buf = xmalloc(LSIZE);
|
||||
*name_buf = NUL;
|
||||
|
||||
if (fp_out == NULL && (flags & (VIF_GET_OLDFILES | VIF_FORCEIT))) {
|
||||
|
@ -3333,7 +3333,7 @@ char_u * enc_canonize(char_u *enc)
|
||||
}
|
||||
|
||||
/* copy "enc" to allocated memory, with room for two '-' */
|
||||
r = alloc((unsigned)(STRLEN(enc) + 3));
|
||||
r = xmalloc(STRLEN(enc) + 3);
|
||||
/* Make it all lower case and replace '_' with '-'. */
|
||||
p = r;
|
||||
for (s = enc; *s != NUL; ++s) {
|
||||
@ -3534,7 +3534,7 @@ static char_u * iconv_string(vimconv_T *vcp, char_u *str, int slen, int *unconvl
|
||||
/* Allocate enough room for most conversions. When re-allocating
|
||||
* increase the buffer size. */
|
||||
len = len + fromlen * 2 + 40;
|
||||
p = alloc((unsigned)len);
|
||||
p = xmalloc(len);
|
||||
if (done > 0)
|
||||
memmove(p, result, done);
|
||||
free(result);
|
||||
@ -3852,7 +3852,7 @@ int convert_input_safe(ptr, len, maxlen, restp, restlenp)
|
||||
if (dlen <= maxlen) {
|
||||
if (unconvertlen > 0) {
|
||||
/* Move the unconverted characters to allocated memory. */
|
||||
*restp = alloc(unconvertlen);
|
||||
*restp = xmalloc(unconvertlen);
|
||||
memmove(*restp, ptr + len - unconvertlen, unconvertlen);
|
||||
*restlenp = unconvertlen;
|
||||
}
|
||||
@ -3908,7 +3908,7 @@ char_u * string_convert_ext(vcp, ptr, lenp, unconvlenp)
|
||||
|
||||
switch (vcp->vc_type) {
|
||||
case CONV_TO_UTF8: /* latin1 to utf-8 conversion */
|
||||
retval = alloc(len * 2 + 1);
|
||||
retval = xmalloc(len * 2 + 1);
|
||||
d = retval;
|
||||
for (i = 0; i < len; ++i) {
|
||||
c = ptr[i];
|
||||
@ -3925,7 +3925,7 @@ char_u * string_convert_ext(vcp, ptr, lenp, unconvlenp)
|
||||
break;
|
||||
|
||||
case CONV_9_TO_UTF8: /* latin9 to utf-8 conversion */
|
||||
retval = alloc(len * 3 + 1);
|
||||
retval = xmalloc(len * 3 + 1);
|
||||
d = retval;
|
||||
for (i = 0; i < len; ++i) {
|
||||
c = ptr[i];
|
||||
@ -3948,7 +3948,7 @@ char_u * string_convert_ext(vcp, ptr, lenp, unconvlenp)
|
||||
|
||||
case CONV_TO_LATIN1: /* utf-8 to latin1 conversion */
|
||||
case CONV_TO_LATIN9: /* utf-8 to latin9 conversion */
|
||||
retval = alloc(len + 1);
|
||||
retval = xmalloc(len + 1);
|
||||
d = retval;
|
||||
for (i = 0; i < len; ++i) {
|
||||
l = utf_ptr2len_len(ptr + i, len - i);
|
||||
|
@ -104,11 +104,9 @@ static void mf_hash_grow(mf_hashtab_T *);
|
||||
*/
|
||||
memfile_T *mf_open(char_u *fname, int flags)
|
||||
{
|
||||
memfile_T *mfp;
|
||||
off_t size;
|
||||
|
||||
if ((mfp = (memfile_T *)alloc((unsigned)sizeof(memfile_T))) == NULL)
|
||||
return NULL;
|
||||
memfile_T *mfp = xmalloc(sizeof(memfile_T));
|
||||
|
||||
if (fname == NULL) { /* no file for this memfile, use memory only */
|
||||
mfp->mf_fname = NULL;
|
||||
@ -323,8 +321,7 @@ bhdr_T *mf_new(memfile_T *mfp, int negative, int page_count)
|
||||
freep->bh_bnum += page_count;
|
||||
freep->bh_page_count -= page_count;
|
||||
} else if (hp == NULL) { /* need to allocate memory for this block */
|
||||
if ((p = (char_u *)alloc(mfp->mf_page_size * page_count)) == NULL)
|
||||
return NULL;
|
||||
p = xmalloc(mfp->mf_page_size * page_count);
|
||||
hp = mf_rem_free(mfp);
|
||||
hp->bh_data = p;
|
||||
} else { /* use the number, remove entry from free list */
|
||||
@ -690,10 +687,7 @@ static bhdr_T *mf_release(memfile_T *mfp, int page_count)
|
||||
*/
|
||||
if (hp->bh_page_count != page_count) {
|
||||
free(hp->bh_data);
|
||||
if ((hp->bh_data = alloc(mfp->mf_page_size * page_count)) == NULL) {
|
||||
free(hp);
|
||||
return NULL;
|
||||
}
|
||||
hp->bh_data = xmalloc(mfp->mf_page_size * page_count);
|
||||
hp->bh_page_count = page_count;
|
||||
}
|
||||
return hp;
|
||||
@ -744,16 +738,10 @@ int mf_release_all(void)
|
||||
*/
|
||||
static bhdr_T *mf_alloc_bhdr(memfile_T *mfp, int page_count)
|
||||
{
|
||||
bhdr_T *hp;
|
||||
bhdr_T *hp = xmalloc(sizeof(bhdr_T));
|
||||
hp->bh_data = xmalloc(mfp->mf_page_size * page_count);
|
||||
hp->bh_page_count = page_count;
|
||||
|
||||
if ((hp = (bhdr_T *)alloc((unsigned)sizeof(bhdr_T))) != NULL) {
|
||||
if ((hp->bh_data = (char_u *)alloc(mfp->mf_page_size * page_count))
|
||||
== NULL) {
|
||||
free(hp); /* not enough memory */
|
||||
return NULL;
|
||||
}
|
||||
hp->bh_page_count = page_count;
|
||||
}
|
||||
return hp;
|
||||
}
|
||||
|
||||
@ -925,14 +913,12 @@ static int mf_trans_add(memfile_T *mfp, bhdr_T *hp)
|
||||
{
|
||||
bhdr_T *freep;
|
||||
blocknr_T new_bnum;
|
||||
NR_TRANS *np;
|
||||
int page_count;
|
||||
|
||||
if (hp->bh_bnum >= 0) /* it's already positive */
|
||||
return OK;
|
||||
|
||||
if ((np = (NR_TRANS *)alloc((unsigned)sizeof(NR_TRANS))) == NULL)
|
||||
return FAIL;
|
||||
NR_TRANS *np = xmalloc(sizeof(NR_TRANS));
|
||||
|
||||
/*
|
||||
* Get a new number for the block.
|
||||
|
@ -1015,7 +1015,7 @@ void ml_recover(void)
|
||||
* 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 = xmalloc(sizeof(buf_T));
|
||||
|
||||
/*
|
||||
* init fields in memline struct
|
||||
@ -1125,7 +1125,7 @@ void ml_recover(void)
|
||||
mfp->mf_infile_count = mfp->mf_blocknr_max;
|
||||
|
||||
/* need to reallocate the memory used to store the data */
|
||||
p = alloc(mfp->mf_page_size);
|
||||
p = xmalloc(mfp->mf_page_size);
|
||||
memmove(p, hp->bh_data, previous_page_size);
|
||||
free(hp->bh_data);
|
||||
hp->bh_data = p;
|
||||
@ -1538,7 +1538,7 @@ recover_names (
|
||||
* 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 = xmalloc(STRLEN(p_dir) + 1);
|
||||
dirp = p_dir;
|
||||
while (dir_name != NULL && *dirp) {
|
||||
/*
|
||||
@ -1612,7 +1612,7 @@ recover_names (
|
||||
char_u *swapname = modname(fname_res, (char_u *)".swp", TRUE);
|
||||
if (swapname != NULL) {
|
||||
if (os_file_exists(swapname)) {
|
||||
files = (char_u **)alloc((unsigned)sizeof(char_u *));
|
||||
files = (char_u **)xmalloc(sizeof(char_u *));
|
||||
files[0] = swapname;
|
||||
swapname = NULL;
|
||||
num_files = 1;
|
||||
@ -2607,8 +2607,9 @@ int ml_replace(linenr_T lnum, char_u *line, int copy)
|
||||
if (curbuf->b_ml.ml_mfp == NULL && open_buffer(FALSE, NULL, 0) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if (copy)
|
||||
if (copy) {
|
||||
line = vim_strsave(line);
|
||||
}
|
||||
if (curbuf->b_ml.ml_line_lnum != lnum) /* other line buffered */
|
||||
ml_flush_line(curbuf); /* flush it */
|
||||
else if (curbuf->b_ml.ml_flags & ML_LINE_DIRTY) /* same line allocated */
|
||||
@ -3539,7 +3540,7 @@ findswapname (
|
||||
* 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 = xmalloc(STRLEN(*dirp) + 1);
|
||||
(void)copy_option_part(dirp, dir_name, 31000, ",");
|
||||
|
||||
/*
|
||||
@ -3666,9 +3667,9 @@ findswapname (
|
||||
if (swap_exists_action != SEA_NONE && choice == 0) {
|
||||
char_u *name;
|
||||
|
||||
name = alloc((unsigned)(STRLEN(fname)
|
||||
+ STRLEN(_("Swap file \""))
|
||||
+ STRLEN(_("\" already exists!")) + 5));
|
||||
name = xmalloc(STRLEN(fname)
|
||||
+ STRLEN(_("Swap file \""))
|
||||
+ STRLEN(_("\" already exists!")) + 5);
|
||||
STRCPY(name, _("Swap file \""));
|
||||
home_replace(NULL, fname, name + STRLEN(name),
|
||||
1000, TRUE);
|
||||
|
@ -44,14 +44,6 @@
|
||||
|
||||
static void try_to_free_memory();
|
||||
|
||||
/*
|
||||
* Note: if unsigned is 16 bits we can only allocate up to 64K with alloc().
|
||||
*/
|
||||
char_u *alloc(unsigned size)
|
||||
{
|
||||
return xmalloc(size);
|
||||
}
|
||||
|
||||
/// Try to free memory. Used when trying to recover from out of memory errors.
|
||||
/// @see {xmalloc}
|
||||
static void try_to_free_memory()
|
||||
|
@ -5,8 +5,6 @@
|
||||
#include "nvim/types.h"
|
||||
#include "nvim/vim.h"
|
||||
|
||||
char_u *alloc(unsigned size) FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE(1);
|
||||
|
||||
/// malloc() wrapper
|
||||
///
|
||||
/// try_malloc() is a malloc() wrapper that tries to free some memory before
|
||||
|
@ -462,7 +462,7 @@ add_menu_path (
|
||||
}
|
||||
|
||||
if (c != 0) {
|
||||
menu->strings[i] = alloc((unsigned)(STRLEN(call_data) + 5 ));
|
||||
menu->strings[i] = xmalloc(STRLEN(call_data) + 5 );
|
||||
menu->strings[i][0] = c;
|
||||
if (d == 0)
|
||||
STRCPY(menu->strings[i] + 1, call_data);
|
||||
|
@ -267,7 +267,7 @@ msg_strtrunc (
|
||||
len = (room + 2) * 2;
|
||||
else
|
||||
len = room + 2;
|
||||
buf = alloc(len);
|
||||
buf = xmalloc(len);
|
||||
trunc_string(s, buf, room, len);
|
||||
}
|
||||
}
|
||||
@ -421,7 +421,7 @@ static char_u *get_emsg_source(void)
|
||||
|
||||
if (sourcing_name != NULL && other_sourcing_name()) {
|
||||
p = (char_u *)_("Error detected while processing %s:");
|
||||
Buf = alloc((unsigned)(STRLEN(sourcing_name) + STRLEN(p)));
|
||||
Buf = xmalloc(STRLEN(sourcing_name) + STRLEN(p));
|
||||
sprintf((char *)Buf, (char *)p, sourcing_name);
|
||||
return Buf;
|
||||
}
|
||||
@ -443,7 +443,7 @@ static char_u *get_emsg_lnum(void)
|
||||
&& (other_sourcing_name() || sourcing_lnum != last_sourcing_lnum)
|
||||
&& sourcing_lnum != 0) {
|
||||
p = (char_u *)_("line %4ld:");
|
||||
Buf = alloc((unsigned)(STRLEN(p) + 20));
|
||||
Buf = xmalloc(STRLEN(p) + 20);
|
||||
sprintf((char *)Buf, (char *)p, (long)sourcing_lnum);
|
||||
return Buf;
|
||||
}
|
||||
@ -680,8 +680,6 @@ add_msg_hist (
|
||||
int attr
|
||||
)
|
||||
{
|
||||
struct msg_hist *p;
|
||||
|
||||
if (msg_hist_off || msg_silent != 0)
|
||||
return;
|
||||
|
||||
@ -690,7 +688,7 @@ add_msg_hist (
|
||||
(void)delete_first_msg();
|
||||
|
||||
/* allocate an entry and add the message at the end of the history */
|
||||
p = (struct msg_hist *)alloc((int)sizeof(struct msg_hist));
|
||||
struct msg_hist *p = xmalloc(sizeof(struct msg_hist));
|
||||
if (len < 0)
|
||||
len = (int)STRLEN(s);
|
||||
/* remove leading and trailing newlines */
|
||||
@ -1841,7 +1839,7 @@ static void inc_msg_scrolled(void)
|
||||
p = (char_u *)_("Unknown");
|
||||
else {
|
||||
len = (int)STRLEN(p) + 40;
|
||||
tofree = alloc(len);
|
||||
tofree = xmalloc(len);
|
||||
vim_snprintf((char *)tofree, len, _("%s line %" PRId64),
|
||||
p, (int64_t)sourcing_lnum);
|
||||
p = tofree;
|
||||
@ -1893,7 +1891,7 @@ store_sb_text (
|
||||
}
|
||||
|
||||
if (s > *sb_str) {
|
||||
mp = (msgchunk_T *)alloc((int)(sizeof(msgchunk_T) + (s - *sb_str)));
|
||||
mp = xmalloc((sizeof(msgchunk_T) + (s - *sb_str)));
|
||||
mp->sb_eol = finish;
|
||||
mp->sb_msg_col = *sb_col;
|
||||
mp->sb_attr = attr;
|
||||
|
@ -501,7 +501,7 @@ open_line (
|
||||
}
|
||||
if (lead_len) {
|
||||
/* allocate buffer (may concatenate p_extra later) */
|
||||
leader = alloc(lead_len + lead_repl_len + extra_space + extra_len
|
||||
leader = xmalloc(lead_len + lead_repl_len + extra_space + extra_len
|
||||
+ (second_line_indent > 0 ? second_line_indent : 0) + 1);
|
||||
allocated = leader; /* remember to free it later */
|
||||
|
||||
@ -1702,9 +1702,7 @@ del_bytes (
|
||||
if (was_alloced)
|
||||
newp = oldp; /* use same allocated memory */
|
||||
else { /* need to allocate a new line */
|
||||
newp = alloc((unsigned)(oldlen + 1 - count));
|
||||
if (newp == NULL)
|
||||
return FAIL;
|
||||
newp = xmalloc(oldlen + 1 - count);
|
||||
memmove(newp, oldp, (size_t)col);
|
||||
}
|
||||
memmove(newp + col, oldp + col + count, (size_t)movelen);
|
||||
@ -2395,7 +2393,7 @@ int get_keystroke(void)
|
||||
* bytes. */
|
||||
maxlen = (buflen - 6 - len) / 3;
|
||||
if (buf == NULL)
|
||||
buf = alloc(buflen);
|
||||
buf = xmalloc(buflen);
|
||||
else if (maxlen < 10) {
|
||||
/* Need some more space. This might happen when receiving a long
|
||||
* escape sequence. */
|
||||
@ -2715,9 +2713,7 @@ char_u *expand_env_save(char_u *src)
|
||||
*/
|
||||
char_u *expand_env_save_opt(char_u *src, int one)
|
||||
{
|
||||
char_u *p;
|
||||
|
||||
p = alloc(MAXPATHL);
|
||||
char_u *p = xmalloc(MAXPATHL);
|
||||
expand_env_esc(src, p, MAXPATHL, FALSE, one, NULL);
|
||||
return p;
|
||||
}
|
||||
@ -2865,8 +2861,9 @@ expand_env_esc (
|
||||
if (p_ssl && var != NULL && vim_strchr(var, '\\') != NULL) {
|
||||
char_u *p = vim_strsave(var);
|
||||
|
||||
if (mustfree)
|
||||
if (mustfree) {
|
||||
free(var);
|
||||
}
|
||||
var = p;
|
||||
mustfree = TRUE;
|
||||
forward_slash(var);
|
||||
@ -3321,13 +3318,12 @@ home_replace_save (
|
||||
)
|
||||
{
|
||||
char_u *dst;
|
||||
unsigned len;
|
||||
|
||||
len = 3; /* space for "~/" and trailing NUL */
|
||||
size_t len = 3; /* space for "~/" and trailing NUL */
|
||||
if (src != NULL) /* just in case */
|
||||
len += (unsigned)STRLEN(src);
|
||||
dst = alloc(len);
|
||||
home_replace(buf, src, dst, len, TRUE);
|
||||
len += STRLEN(src);
|
||||
dst = xmalloc(len);
|
||||
home_replace(buf, src, dst, (int)len, TRUE);
|
||||
return dst;
|
||||
}
|
||||
|
||||
@ -3488,7 +3484,7 @@ get_cmd_output (
|
||||
len = ftell(fd); /* get size of temp file */
|
||||
fseek(fd, 0L, SEEK_SET);
|
||||
|
||||
buffer = alloc(len + 1);
|
||||
buffer = xmalloc(len + 1);
|
||||
i = (int)fread((char *)buffer, (size_t)1, (size_t)len, fd);
|
||||
fclose(fd);
|
||||
os_remove((char *)tempname);
|
||||
|
@ -230,7 +230,7 @@ coladvance2 (
|
||||
if (line[idx] == NUL) {
|
||||
/* Append spaces */
|
||||
int correct = wcol - col;
|
||||
char_u *newline = alloc(idx + correct + 1);
|
||||
char_u *newline = xmalloc(idx + correct + 1);
|
||||
int t;
|
||||
|
||||
for (t = 0; t < idx; ++t)
|
||||
@ -256,7 +256,7 @@ coladvance2 (
|
||||
if (-correct > csize)
|
||||
return FAIL;
|
||||
|
||||
newline = alloc(linelen + csize);
|
||||
newline = xmalloc(linelen + csize);
|
||||
|
||||
for (t = 0; t < linelen; t++) {
|
||||
if (t != idx)
|
||||
|
@ -3382,7 +3382,7 @@ find_decl (
|
||||
int retval = OK;
|
||||
int incll;
|
||||
|
||||
pat = alloc(len + 7);
|
||||
pat = xmalloc(len + 7);
|
||||
|
||||
/* Put "\V" before the pattern to avoid that the special meaning of "."
|
||||
* and "~" causes trouble. */
|
||||
@ -4356,7 +4356,7 @@ static void nv_ident(cmdarg_T *cap)
|
||||
kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp);
|
||||
kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0
|
||||
|| STRCMP(kp, ":help") == 0);
|
||||
buf = alloc((unsigned)(n * 2 + 30 + STRLEN(kp)));
|
||||
buf = xmalloc(n * 2 + 30 + STRLEN(kp));
|
||||
buf[0] = NUL;
|
||||
|
||||
switch (cmdchar) {
|
||||
|
@ -905,7 +905,7 @@ static int stuff_yank(int regname, char_u *p)
|
||||
*pp = lp;
|
||||
} else {
|
||||
free_yank_all();
|
||||
y_current->y_array = (char_u **)alloc((unsigned)sizeof(char_u *));
|
||||
y_current->y_array = (char_u **)xmalloc(sizeof(char_u *));
|
||||
y_current->y_array[0] = p;
|
||||
y_current->y_size = 1;
|
||||
y_current->y_type = MCHAR; /* used to be MLINE, why? */
|
||||
@ -2664,8 +2664,7 @@ do_put (
|
||||
}
|
||||
if (y_array != NULL)
|
||||
break;
|
||||
y_array = (char_u **)alloc((unsigned)
|
||||
(y_size * sizeof(char_u *)));
|
||||
y_array = (char_u **)xmalloc(y_size * sizeof(char_u *));
|
||||
}
|
||||
} else {
|
||||
y_size = 1; /* use fake one-line yank register */
|
||||
@ -4384,7 +4383,7 @@ int do_addsub(int command, linenr_T Prenum1)
|
||||
* When there are many leading zeros it could be very long. Allocate
|
||||
* a bit too much.
|
||||
*/
|
||||
buf1 = alloc((unsigned)length + NUMBUFLEN);
|
||||
buf1 = xmalloc(length + NUMBUFLEN);
|
||||
ptr = buf1;
|
||||
if (negative) {
|
||||
*ptr++ = '-';
|
||||
@ -4474,7 +4473,7 @@ int read_viminfo_register(vir_T *virp, int force)
|
||||
y_previous = y_current;
|
||||
free(y_current->y_array);
|
||||
array = y_current->y_array =
|
||||
(char_u **)alloc((unsigned)(limit * sizeof(char_u *)));
|
||||
(char_u **)xmalloc(limit * sizeof(char_u *));
|
||||
str = skipwhite(skiptowhite(str));
|
||||
if (STRNCMP(str, "CHAR", 4) == 0)
|
||||
y_current->y_type = MCHAR;
|
||||
@ -4491,8 +4490,7 @@ int read_viminfo_register(vir_T *virp, int force)
|
||||
&& (virp->vir_line[0] == TAB || virp->vir_line[0] == '<')) {
|
||||
if (do_it) {
|
||||
if (size >= limit) {
|
||||
y_current->y_array = (char_u **)
|
||||
alloc((unsigned)(limit * 2 * sizeof(char_u *)));
|
||||
y_current->y_array = (char_u **)xmalloc(limit * 2 * sizeof(char_u *));
|
||||
for (i = 0; i < limit; i++)
|
||||
y_current->y_array[i] = array[i];
|
||||
free(array);
|
||||
@ -4512,7 +4510,7 @@ int read_viminfo_register(vir_T *virp, int force)
|
||||
y_current->y_array = NULL;
|
||||
} else if (size < limit) {
|
||||
y_current->y_array =
|
||||
(char_u **)alloc((unsigned)(size * sizeof(char_u *)));
|
||||
(char_u **)xmalloc(size * sizeof(char_u *));
|
||||
for (i = 0; i < size; i++)
|
||||
y_current->y_array[i] = array[i];
|
||||
free(array);
|
||||
@ -4867,7 +4865,7 @@ str_to_reg (
|
||||
extra = (int)STRLEN(y_ptr->y_array[lnum]);
|
||||
} else
|
||||
extra = 0;
|
||||
s = alloc((unsigned)(i + extra + 1));
|
||||
s = xmalloc(i + extra + 1);
|
||||
if (extra)
|
||||
memmove(s, y_ptr->y_array[lnum], (size_t)extra);
|
||||
if (append)
|
||||
|
@ -3083,7 +3083,7 @@ do_set (
|
||||
newlen = (unsigned)STRLEN(arg) + 1;
|
||||
if (adding || prepending || removing)
|
||||
newlen += (unsigned)STRLEN(origval) + 1;
|
||||
newval = alloc(newlen);
|
||||
newval = xmalloc(newlen);
|
||||
s = newval;
|
||||
|
||||
/*
|
||||
@ -3129,7 +3129,7 @@ do_set (
|
||||
newlen = (unsigned)STRLEN(s) + 1;
|
||||
if (adding || prepending || removing)
|
||||
newlen += (unsigned)STRLEN(origval) + 1;
|
||||
newval = alloc(newlen);
|
||||
newval = xmalloc(newlen);
|
||||
STRCPY(newval, s);
|
||||
}
|
||||
}
|
||||
@ -4828,7 +4828,7 @@ skip:
|
||||
if (count == 0)
|
||||
wp->w_p_cc_cols = NULL;
|
||||
else {
|
||||
wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
|
||||
wp->w_p_cc_cols = xmalloc(sizeof(int) * (count + 1));
|
||||
/* sort the columns for faster usage on screen redraw inside
|
||||
* win_line() */
|
||||
qsort(color_cols, count, sizeof(int), int_cmp);
|
||||
@ -6204,7 +6204,6 @@ showoptions (
|
||||
int col;
|
||||
int isterm;
|
||||
char_u *varp;
|
||||
struct vimoption **items;
|
||||
int item_count;
|
||||
int run;
|
||||
int row, rows;
|
||||
@ -6215,8 +6214,7 @@ showoptions (
|
||||
#define INC 20
|
||||
#define GAP 3
|
||||
|
||||
items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
|
||||
PARAM_COUNT));
|
||||
struct vimoption **items = xmalloc(sizeof(struct vimoption *) * PARAM_COUNT);
|
||||
|
||||
/* Highlight title */
|
||||
if (all == 2)
|
||||
@ -6505,7 +6503,7 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int e
|
||||
if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
|
||||
return FAIL;
|
||||
} else if (expand) {
|
||||
buf = alloc(MAXPATHL);
|
||||
buf = xmalloc(MAXPATHL);
|
||||
home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
|
||||
if (put_escstr(fd, buf, 2) == FAIL) {
|
||||
free(buf);
|
||||
@ -7525,11 +7523,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***
|
||||
*num_file = num_term;
|
||||
else
|
||||
return OK;
|
||||
*file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
|
||||
if (*file == NULL) {
|
||||
*file = (char_u **)"";
|
||||
return FAIL;
|
||||
}
|
||||
*file = (char_u **)xmalloc(*num_file * sizeof(char_u *));
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
@ -7541,7 +7535,7 @@ int ExpandOldSetting(int *num_file, char_u ***file)
|
||||
char_u *buf;
|
||||
|
||||
*num_file = 0;
|
||||
*file = (char_u **)alloc((unsigned)sizeof(char_u *));
|
||||
*file = (char_u **)xmalloc(sizeof(char_u *));
|
||||
|
||||
/*
|
||||
* For a terminal key code expand_option_idx is < 0.
|
||||
|
@ -89,8 +89,8 @@ static bool is_executable_in_path(const char_u *name)
|
||||
return false;
|
||||
}
|
||||
|
||||
int buf_len = STRLEN(name) + STRLEN(path) + 2;
|
||||
char_u *buf = alloc((unsigned)(buf_len));
|
||||
size_t buf_len = STRLEN(name) + STRLEN(path) + 2;
|
||||
char_u *buf = xmalloc(buf_len);
|
||||
|
||||
// Walk through all entries in $PATH to check if "name" exists there and
|
||||
// is an executable file.
|
||||
@ -103,7 +103,7 @@ static bool is_executable_in_path(const char_u *name)
|
||||
// Glue together the given directory from $PATH with name and save into
|
||||
// buf.
|
||||
vim_strncpy(buf, (char_u *) path, e - path);
|
||||
append_path((char *) buf, (const char *) name, buf_len);
|
||||
append_path((char *) buf, (const char *) name, (int)buf_len);
|
||||
|
||||
if (is_executable(buf)) {
|
||||
// Found our executable. Free buf and return.
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "nvim/os/os.h"
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/misc2.h"
|
||||
#include "nvim/strings.h"
|
||||
#ifdef HAVE_PWD_H
|
||||
@ -76,7 +77,7 @@ char *os_get_user_directory(const char *name)
|
||||
pw = getpwnam(name);
|
||||
if (pw != NULL) {
|
||||
// save the string from the static passwd entry into malloced memory
|
||||
return vim_strsave(pw->pw_dir);
|
||||
return xstrdup(pw->pw_dir);
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
|
@ -1120,7 +1120,7 @@ int flags; /* EW_* flags */
|
||||
++len;
|
||||
}
|
||||
}
|
||||
command = alloc(len);
|
||||
command = xmalloc(len);
|
||||
|
||||
/*
|
||||
* Build the shell command:
|
||||
@ -1269,7 +1269,7 @@ int flags; /* EW_* flags */
|
||||
fseek(fd, 0L, SEEK_END);
|
||||
len = ftell(fd); /* get size of temp file */
|
||||
fseek(fd, 0L, SEEK_SET);
|
||||
buffer = alloc(len + 1);
|
||||
buffer = xmalloc(len + 1);
|
||||
i = fread((char *)buffer, 1, len, fd);
|
||||
fclose(fd);
|
||||
os_remove((char *)tempname);
|
||||
@ -1353,7 +1353,7 @@ int flags; /* EW_* flags */
|
||||
goto notfound;
|
||||
}
|
||||
*num_file = i;
|
||||
*file = (char_u **)alloc(sizeof(char_u *) * i);
|
||||
*file = (char_u **)xmalloc(sizeof(char_u *) * i);
|
||||
|
||||
/*
|
||||
* Isolate the individual file names.
|
||||
@ -1397,7 +1397,7 @@ int flags; /* EW_* flags */
|
||||
if (!dir && (flags & EW_EXEC) && !os_can_exe((*file)[i]))
|
||||
continue;
|
||||
|
||||
p = alloc((unsigned)(STRLEN((*file)[i]) + 1 + dir));
|
||||
p = xmalloc(STRLEN((*file)[i]) + 1 + dir);
|
||||
STRCPY(p, (*file)[i]);
|
||||
if (dir)
|
||||
add_pathsep(p); /* add '/' to a directory name */
|
||||
|
@ -312,10 +312,11 @@ FullName_save (
|
||||
|
||||
char_u *buf = xmalloc(MAXPATHL);
|
||||
|
||||
if (vim_FullName(fname, buf, MAXPATHL, force) != FAIL)
|
||||
if (vim_FullName(fname, buf, MAXPATHL, force) != FAIL) {
|
||||
new_fname = vim_strsave(buf);
|
||||
else
|
||||
} else {
|
||||
new_fname = vim_strsave(fname);
|
||||
}
|
||||
free(buf);
|
||||
|
||||
return new_fname;
|
||||
@ -379,7 +380,7 @@ unix_expandpath (
|
||||
}
|
||||
|
||||
/* make room for file name */
|
||||
buf = alloc((int)STRLEN(path) + BASENAMELEN + 5);
|
||||
buf = xmalloc(STRLEN(path) + BASENAMELEN + 5);
|
||||
|
||||
/*
|
||||
* Find the first part in the path name that contains a wildcard.
|
||||
@ -608,7 +609,7 @@ static void expand_path_option(char_u *curdir, garray_T *gap)
|
||||
char_u *p;
|
||||
int len;
|
||||
|
||||
buf = alloc((int)MAXPATHL);
|
||||
buf = xmalloc(MAXPATHL);
|
||||
|
||||
while (*path_option != NUL) {
|
||||
copy_option_part(&path_option, buf, MAXPATHL, " ,");
|
||||
@ -720,7 +721,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
|
||||
* possible patterns?
|
||||
*/
|
||||
len = (int)STRLEN(pattern);
|
||||
file_pattern = alloc(len + 2);
|
||||
file_pattern = xmalloc(len + 2);
|
||||
file_pattern[0] = '*';
|
||||
file_pattern[1] = NUL;
|
||||
STRCAT(file_pattern, pattern);
|
||||
@ -735,7 +736,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
|
||||
if (regmatch.regprog == NULL)
|
||||
return;
|
||||
|
||||
curdir = alloc((int)(MAXPATHL));
|
||||
curdir = xmalloc(MAXPATHL);
|
||||
os_dirname(curdir, MAXPATHL);
|
||||
expand_path_option(curdir, &path_ga);
|
||||
|
||||
@ -811,7 +812,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
|
||||
continue;
|
||||
}
|
||||
|
||||
rel_path = alloc((int)(STRLEN(short_name) + STRLEN(PATHSEPSTR) + 2));
|
||||
rel_path = xmalloc(STRLEN(short_name) + STRLEN(PATHSEPSTR) + 2);
|
||||
STRCPY(rel_path, ".");
|
||||
add_pathsep(rel_path);
|
||||
STRCAT(rel_path, short_name);
|
||||
@ -884,7 +885,7 @@ expand_in_path (
|
||||
char_u *e; /* end */
|
||||
char_u *paths = NULL;
|
||||
|
||||
curdir = alloc((unsigned)MAXPATHL);
|
||||
curdir = xmalloc(MAXPATHL);
|
||||
os_dirname(curdir, MAXPATHL);
|
||||
|
||||
ga_init(&path_ga, (int)sizeof(char_u *), 1);
|
||||
@ -1206,7 +1207,7 @@ addfile (
|
||||
/* Make room for another item in the file list. */
|
||||
ga_grow(gap, 1);
|
||||
|
||||
p = alloc((unsigned)(STRLEN(f) + 1 + isdir));
|
||||
p = xmalloc(STRLEN(f) + 1 + isdir);
|
||||
|
||||
STRCPY(p, f);
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
|
@ -283,9 +283,9 @@ qf_init_ext (
|
||||
{'s', ".\\+"}
|
||||
};
|
||||
|
||||
namebuf = alloc(CMDBUFFSIZE + 1);
|
||||
errmsg = alloc(CMDBUFFSIZE + 1);
|
||||
pattern = alloc(CMDBUFFSIZE + 1);
|
||||
namebuf = xmalloc(CMDBUFFSIZE + 1);
|
||||
errmsg = xmalloc(CMDBUFFSIZE + 1);
|
||||
pattern = xmalloc(CMDBUFFSIZE + 1);
|
||||
|
||||
if (efile != NULL && (fd = mch_fopen((char *)efile, "r")) == NULL) {
|
||||
EMSG2(_(e_openerrf), efile);
|
||||
@ -321,7 +321,7 @@ qf_init_ext (
|
||||
#else
|
||||
i += 2; /* "%f" can become two chars longer */
|
||||
#endif
|
||||
fmtstr = alloc(i);
|
||||
fmtstr = xmalloc(i);
|
||||
|
||||
while (efm[0] != NUL) {
|
||||
/*
|
||||
@ -720,7 +720,7 @@ restofline:
|
||||
goto error2;
|
||||
if (*errmsg && !multiignore) {
|
||||
len = (int)STRLEN(qfprev->qf_text);
|
||||
ptr = alloc((unsigned)(len + STRLEN(errmsg) + 2));
|
||||
ptr = xmalloc(len + STRLEN(errmsg) + 2);
|
||||
STRCPY(ptr, qfprev->qf_text);
|
||||
free(qfprev->qf_text);
|
||||
qfprev->qf_text = ptr;
|
||||
@ -856,7 +856,7 @@ static void qf_new_list(qf_info_T *qi, char_u *qf_title)
|
||||
qi->qf_curlist = qi->qf_listcount++;
|
||||
memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T)));
|
||||
if (qf_title != NULL) {
|
||||
char_u *p = alloc((int)STRLEN(qf_title) + 2);
|
||||
char_u *p = xmalloc(STRLEN(qf_title) + 2);
|
||||
|
||||
qi->qf_lists[qi->qf_curlist].qf_title = p;
|
||||
sprintf((char *)p, ":%s", (char *)qf_title);
|
||||
@ -921,9 +921,7 @@ qf_add_entry (
|
||||
int valid /* valid entry */
|
||||
)
|
||||
{
|
||||
qfline_T *qfp;
|
||||
|
||||
qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T));
|
||||
qfline_T *qfp = xmalloc(sizeof(qfline_T));
|
||||
|
||||
if (bufnum != 0)
|
||||
qfp->qf_fnum = bufnum;
|
||||
@ -1140,11 +1138,10 @@ static int qf_get_fnum(char_u *directory, char_u *fname)
|
||||
*/
|
||||
static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr)
|
||||
{
|
||||
struct dir_stack_T *ds_new;
|
||||
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));
|
||||
struct dir_stack_T *ds_new = xmalloc(sizeof(struct dir_stack_T));
|
||||
|
||||
ds_new->next = *stackptr;
|
||||
*stackptr = ds_new;
|
||||
@ -2516,7 +2513,7 @@ void ex_make(exarg_T *eap)
|
||||
len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(eap->arg) + 1;
|
||||
if (*p_sp != NUL)
|
||||
len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3;
|
||||
cmd = alloc(len);
|
||||
cmd = xmalloc(len);
|
||||
sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg,
|
||||
(char *)p_shq);
|
||||
if (*p_sp != NUL)
|
||||
@ -2591,7 +2588,7 @@ static char_u *get_mef_name(void)
|
||||
else
|
||||
off += 19;
|
||||
|
||||
name = alloc((unsigned)STRLEN(p_mef) + 30);
|
||||
name = xmalloc(STRLEN(p_mef) + 30);
|
||||
STRCPY(name, p_mef);
|
||||
sprintf((char *)name + (p - p_mef), "%d%d", start, off);
|
||||
STRCAT(name, p + 2);
|
||||
@ -2838,8 +2835,8 @@ void ex_vimgrep(exarg_T *eap)
|
||||
goto theend;
|
||||
}
|
||||
|
||||
dirname_start = alloc(MAXPATHL);
|
||||
dirname_now = alloc(MAXPATHL);
|
||||
dirname_start = xmalloc(MAXPATHL);
|
||||
dirname_now = xmalloc(MAXPATHL);
|
||||
|
||||
/* Remember the current directory, because a BufRead autocommand that does
|
||||
* ":lcd %:p:h" changes the meaning of short path names. */
|
||||
@ -3107,7 +3104,7 @@ char_u *skip_vimgrep_pat(char_u *p, char_u **s, int *flags)
|
||||
*/
|
||||
static void restore_start_dir(char_u *dirname_start)
|
||||
{
|
||||
char_u *dirname_now = alloc(MAXPATHL);
|
||||
char_u *dirname_now = xmalloc(MAXPATHL);
|
||||
|
||||
os_dirname(dirname_now, MAXPATHL);
|
||||
if (STRCMP(dirname_start, dirname_now) != 0) {
|
||||
|
@ -5653,7 +5653,7 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e
|
||||
if (reg_tofree == NULL || len >= (int)reg_tofreelen) {
|
||||
len += 50; /* get some extra */
|
||||
free(reg_tofree);
|
||||
reg_tofree = alloc(len);
|
||||
reg_tofree = xmalloc(len);
|
||||
reg_tofreelen = len;
|
||||
}
|
||||
STRCPY(reg_tofree, regline);
|
||||
@ -6404,7 +6404,7 @@ char_u *regtilde(char_u *source, int magic)
|
||||
if (reg_prev_sub != NULL) {
|
||||
/* length = len(newsub) - 1 + len(prev_sub) + 1 */
|
||||
prevlen = (int)STRLEN(reg_prev_sub);
|
||||
tmpsub = alloc((unsigned)(STRLEN(newsub) + prevlen));
|
||||
tmpsub = xmalloc(STRLEN(newsub) + prevlen);
|
||||
/* copy prefix */
|
||||
len = (int)(p - newsub); /* not including ~ */
|
||||
memmove(tmpsub, newsub, (size_t)len);
|
||||
|
@ -516,7 +516,7 @@ static char_u *nfa_get_match_text(nfa_state_T *start)
|
||||
if (p->c != NFA_MCLOSE || p->out->c != NFA_MATCH)
|
||||
return NULL;
|
||||
|
||||
ret = alloc(len);
|
||||
ret = xmalloc(len);
|
||||
p = start->out->out; /* skip first char, it goes into regstart */
|
||||
s = ret;
|
||||
while (p->c > 0) {
|
||||
@ -4193,10 +4193,9 @@ addstate_here (
|
||||
if (l->n + count - 1 >= l->len) {
|
||||
/* not enough space to move the new states, reallocate the list
|
||||
* and move the states to the right position */
|
||||
nfa_thread_T *newl;
|
||||
|
||||
l->len = l->len * 3 / 2 + 50;
|
||||
newl = (nfa_thread_T *)alloc(l->len * sizeof(nfa_thread_T));
|
||||
nfa_thread_T *newl = xmalloc(l->len * sizeof(nfa_thread_T));
|
||||
memmove(&(newl[0]),
|
||||
&(l->t[0]),
|
||||
sizeof(nfa_thread_T) * listidx);
|
||||
|
@ -4692,9 +4692,9 @@ win_redr_status_matches (
|
||||
return;
|
||||
|
||||
if (has_mbyte)
|
||||
buf = alloc((unsigned)Columns * MB_MAXBYTES + 1);
|
||||
buf = xmalloc(Columns * MB_MAXBYTES + 1);
|
||||
else
|
||||
buf = alloc((unsigned)Columns + 1);
|
||||
buf = xmalloc(Columns + 1);
|
||||
|
||||
if (match == -1) { /* don't show match but original text */
|
||||
match = 0;
|
||||
|
@ -234,31 +234,23 @@ char_u *get_search_pat(void)
|
||||
*/
|
||||
char_u *reverse_text(char_u *s)
|
||||
{
|
||||
unsigned len;
|
||||
unsigned s_i, rev_i;
|
||||
char_u *rev;
|
||||
|
||||
/*
|
||||
* Reverse the pattern.
|
||||
*/
|
||||
len = (unsigned)STRLEN(s);
|
||||
rev = alloc(len + 1);
|
||||
if (rev != NULL) {
|
||||
rev_i = len;
|
||||
for (s_i = 0; s_i < len; ++s_i) {
|
||||
if (has_mbyte) {
|
||||
int mb_len;
|
||||
|
||||
mb_len = (*mb_ptr2len)(s + s_i);
|
||||
rev_i -= mb_len;
|
||||
memmove(rev + rev_i, s + s_i, mb_len);
|
||||
s_i += mb_len - 1;
|
||||
} else
|
||||
rev[--rev_i] = s[s_i];
|
||||
|
||||
}
|
||||
rev[len] = NUL;
|
||||
size_t len = STRLEN(s);
|
||||
char_u *rev = xmalloc(len + 1);
|
||||
size_t rev_i = len;
|
||||
for (size_t s_i = 0; s_i < len; ++s_i) {
|
||||
if (has_mbyte) {
|
||||
int mb_len = (*mb_ptr2len)(s + s_i);
|
||||
rev_i -= mb_len;
|
||||
memmove(rev + rev_i, s + s_i, mb_len);
|
||||
s_i += mb_len - 1;
|
||||
} else
|
||||
rev[--rev_i] = s[s_i];
|
||||
}
|
||||
rev[len] = NUL;
|
||||
|
||||
return rev;
|
||||
}
|
||||
|
||||
@ -1056,8 +1048,8 @@ proftime_T *tm; /* timeout limit or NULL */
|
||||
p = spats[last_idx].pat;
|
||||
else
|
||||
p = searchstr;
|
||||
msgbuf = alloc((unsigned)(STRLEN(p) + 40));
|
||||
if (msgbuf != NULL) {
|
||||
msgbuf = xmalloc(STRLEN(p) + 40);
|
||||
{
|
||||
msgbuf[0] = dirc;
|
||||
if (enc_utf8 && utf_iscomposing(utf_ptr2char(p))) {
|
||||
/* Use a space to draw the composing char on. */
|
||||
@ -3257,14 +3249,8 @@ again:
|
||||
curwin->w_cursor = old_pos;
|
||||
goto theend;
|
||||
}
|
||||
spat = alloc(len + 31);
|
||||
epat = alloc(len + 9);
|
||||
if (spat == NULL || epat == NULL) {
|
||||
free(spat);
|
||||
free(epat);
|
||||
curwin->w_cursor = old_pos;
|
||||
goto theend;
|
||||
}
|
||||
spat = xmalloc(len + 31);
|
||||
epat = xmalloc(len + 9);
|
||||
sprintf((char *)spat, "<%.*s\\>\\%%(\\s\\_[^>]\\{-}[^/]>\\|>\\)\\c", len, p);
|
||||
sprintf((char *)epat, "</%.*s>\\c", len, p);
|
||||
|
||||
@ -4024,18 +4010,14 @@ find_pattern_in_path (
|
||||
incl_regmatch.regprog = NULL;
|
||||
def_regmatch.regprog = NULL;
|
||||
|
||||
file_line = alloc(LSIZE);
|
||||
if (file_line == NULL)
|
||||
return;
|
||||
file_line = xmalloc(LSIZE);
|
||||
|
||||
if (type != CHECK_PATH && type != FIND_DEFINE
|
||||
/* when CONT_SOL is set compare "ptr" with the beginning of the line
|
||||
* is faster than quote_meta/regcomp/regexec "ptr" -- Acevedo */
|
||||
&& !(compl_cont_status & CONT_SOL)
|
||||
) {
|
||||
pat = alloc(len + 5);
|
||||
if (pat == NULL)
|
||||
goto fpip_end;
|
||||
pat = xmalloc(len + 5);
|
||||
sprintf((char *)pat, whole ? "\\<%.*s\\>" : "%.*s", len, ptr);
|
||||
/* ignore case according to p_ic, p_scs and pat */
|
||||
regmatch.rm_ic = ignorecase(pat);
|
||||
|
@ -2010,7 +2010,7 @@ spell_move_to (
|
||||
if (buflen < len + MAXWLEN + 2) {
|
||||
free(buf);
|
||||
buflen = len + MAXWLEN + 2;
|
||||
buf = alloc(buflen);
|
||||
buf = xmalloc(buflen);
|
||||
}
|
||||
|
||||
// In first line check first word for Capital.
|
||||
@ -2854,7 +2854,7 @@ static int read_sal_section(FILE *fd, slang_T *slang)
|
||||
ccnt = getc(fd); // <salfromlen>
|
||||
if (ccnt < 0)
|
||||
return SP_TRUNCERROR;
|
||||
p = alloc(ccnt + 2);
|
||||
p = xmalloc(ccnt + 2);
|
||||
smp->sm_lead = p;
|
||||
|
||||
// Read up to the first special char into sm_lead.
|
||||
@ -2917,7 +2917,7 @@ static int read_sal_section(FILE *fd, slang_T *slang)
|
||||
// Add one extra entry to mark the end with an empty sm_lead. Avoids
|
||||
// that we need to check the index every time.
|
||||
smp = &((salitem_T *)gap->ga_data)[gap->ga_len];
|
||||
p = alloc(1);
|
||||
p = xmalloc(1);
|
||||
p[0] = NUL;
|
||||
smp->sm_lead = p;
|
||||
smp->sm_leadlen = 0;
|
||||
@ -2994,7 +2994,7 @@ count_common_word (
|
||||
hash = hash_hash(p);
|
||||
hi = hash_lookup(&lp->sl_wordcount, p, hash);
|
||||
if (HASHITEM_EMPTY(hi)) {
|
||||
wc = (wordcount_T *)alloc((unsigned)(sizeof(wordcount_T) + STRLEN(p)));
|
||||
wc = xmalloc(sizeof(wordcount_T) + STRLEN(p));
|
||||
STRCPY(wc->wc_word, p);
|
||||
wc->wc_count = count;
|
||||
hash_add_item(&lp->sl_wordcount, hi, wc->wc_word, hash);
|
||||
@ -3144,22 +3144,22 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
|
||||
c = todo * 2 + 7;
|
||||
if (enc_utf8)
|
||||
c += todo * 2;
|
||||
pat = alloc((unsigned)c);
|
||||
pat = xmalloc(c);
|
||||
|
||||
// We also need a list of all flags that can appear at the start and one
|
||||
// for all flags.
|
||||
cp = alloc(todo + 1);
|
||||
cp = xmalloc(todo + 1);
|
||||
slang->sl_compstartflags = cp;
|
||||
*cp = NUL;
|
||||
|
||||
ap = alloc(todo + 1);
|
||||
ap = xmalloc(todo + 1);
|
||||
slang->sl_compallflags = ap;
|
||||
*ap = NUL;
|
||||
|
||||
// And a list of all patterns in their original form, for checking whether
|
||||
// compounding may work in match_compoundrule(). This is freed when we
|
||||
// encounter a wildcard, the check doesn't work then.
|
||||
crp = alloc(todo + 1);
|
||||
crp = xmalloc(todo + 1);
|
||||
slang->sl_comprules = crp;
|
||||
|
||||
pp = pat;
|
||||
@ -3376,7 +3376,7 @@ static int set_sofo(slang_T *lp, char_u *from, char_u *to)
|
||||
// Allocate the lists.
|
||||
for (i = 0; i < 256; ++i)
|
||||
if (lp->sl_sal_first[i] > 0) {
|
||||
p = alloc(sizeof(int) * (lp->sl_sal_first[i] * 2 + 1));
|
||||
p = xmalloc(sizeof(int) * (lp->sl_sal_first[i] * 2 + 1));
|
||||
((int **)gap->ga_data)[i] = (int *)p;
|
||||
*(int *)p = 0;
|
||||
}
|
||||
@ -7374,7 +7374,7 @@ static void spell_make_sugfile(spellinfo_T *spin, char_u *wfname)
|
||||
|
||||
// Write the .sug file.
|
||||
// Make the file name by changing ".spl" to ".sug".
|
||||
fname = alloc(MAXPATHL);
|
||||
fname = xmalloc(MAXPATHL);
|
||||
vim_strncpy(fname, wfname, MAXPATHL - 1);
|
||||
len = (int)STRLEN(fname);
|
||||
fname[len - 2] = 'u';
|
||||
@ -7782,7 +7782,7 @@ mkspell (
|
||||
innames = &fnames[1];
|
||||
incount = fcount - 1;
|
||||
|
||||
wfname = alloc(MAXPATHL);
|
||||
wfname = xmalloc(MAXPATHL);
|
||||
|
||||
if (fcount >= 1) {
|
||||
len = (int)STRLEN(fnames[0]);
|
||||
@ -7833,7 +7833,7 @@ mkspell (
|
||||
goto theend;
|
||||
}
|
||||
|
||||
fname = alloc(MAXPATHL);
|
||||
fname = xmalloc(MAXPATHL);
|
||||
|
||||
// Init the aff and dic pointers.
|
||||
// Get the region names if there are more than 2 arguments.
|
||||
@ -8025,7 +8025,7 @@ spell_add_word (
|
||||
EMSG2(_(e_notset), "spellfile");
|
||||
return;
|
||||
}
|
||||
fnamebuf = alloc(MAXPATHL);
|
||||
fnamebuf = xmalloc(MAXPATHL);
|
||||
|
||||
for (spf = curwin->w_s->b_p_spf, i = 1; *spf != NUL; ++i) {
|
||||
copy_option_part(&spf, fnamebuf, MAXPATHL, ",");
|
||||
@ -8144,7 +8144,7 @@ static void init_spellfile(void)
|
||||
char_u *lstart = curbuf->b_s.b_p_spl;
|
||||
|
||||
if (*curwin->w_s->b_p_spl != NUL && !GA_EMPTY(&curwin->w_s->b_langp)) {
|
||||
buf = alloc(MAXPATHL);
|
||||
buf = xmalloc(MAXPATHL);
|
||||
|
||||
// Find the end of the language name. Exclude the region. If there
|
||||
// is a path separator remember the start of the tail.
|
||||
@ -8787,8 +8787,7 @@ void spell_suggest(int count)
|
||||
}
|
||||
|
||||
// Replace the word.
|
||||
p = alloc((unsigned)STRLEN(line) - stp->st_orglen
|
||||
+ stp->st_wordlen + 1);
|
||||
p = xmalloc(STRLEN(line) - stp->st_orglen + stp->st_wordlen + 1);
|
||||
c = (int)(sug.su_badptr - line);
|
||||
memmove(p, line, c);
|
||||
STRCPY(p + c, stp->st_word);
|
||||
@ -8886,7 +8885,7 @@ void ex_spellrepall(exarg_T *eap)
|
||||
}
|
||||
addlen = (int)(STRLEN(repl_to) - STRLEN(repl_from));
|
||||
|
||||
frompat = alloc((unsigned)STRLEN(repl_from) + 7);
|
||||
frompat = xmalloc(STRLEN(repl_from) + 7);
|
||||
sprintf((char *)frompat, "\\V\\<%s\\>", repl_from);
|
||||
p_ws = FALSE;
|
||||
|
||||
@ -8903,7 +8902,7 @@ void ex_spellrepall(exarg_T *eap)
|
||||
line = ml_get_curline();
|
||||
if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col,
|
||||
repl_to, STRLEN(repl_to)) != 0) {
|
||||
p = alloc((unsigned)STRLEN(line) + addlen + 1);
|
||||
p = xmalloc(STRLEN(line) + addlen + 1);
|
||||
memmove(p, line, curwin->w_cursor.col);
|
||||
STRCPY(p + curwin->w_cursor.col, repl_to);
|
||||
STRCAT(p, line + curwin->w_cursor.col + STRLEN(repl_from));
|
||||
@ -8955,8 +8954,8 @@ spell_suggest_list (
|
||||
|
||||
// The suggested word may replace only part of "word", add the not
|
||||
// replaced part.
|
||||
wcopy = alloc(stp->st_wordlen
|
||||
+ (unsigned)STRLEN(sug.su_badptr + stp->st_orglen) + 1);
|
||||
wcopy = xmalloc(stp->st_wordlen
|
||||
+ STRLEN(sug.su_badptr + stp->st_orglen) + 1);
|
||||
STRCPY(wcopy, stp->st_word);
|
||||
STRCPY(wcopy + stp->st_wordlen, sug.su_badptr + stp->st_orglen);
|
||||
((char_u **)gap->ga_data)[gap->ga_len++] = wcopy;
|
||||
@ -11298,8 +11297,7 @@ add_sound_suggest (
|
||||
hash = hash_hash(goodword);
|
||||
hi = hash_lookup(&slang->sl_sounddone, goodword, hash);
|
||||
if (HASHITEM_EMPTY(hi)) {
|
||||
sft = (sftword_T *)alloc((unsigned)(sizeof(sftword_T)
|
||||
+ STRLEN(goodword)));
|
||||
sft = xmalloc(sizeof(sftword_T) + STRLEN(goodword));
|
||||
sft->sft_score = score;
|
||||
STRCPY(sft->sft_word, goodword);
|
||||
hash_add_item(&slang->sl_sounddone, hi, sft->sft_word, hash);
|
||||
@ -11563,7 +11561,7 @@ static void set_map_str(slang_T *lp, char_u *map)
|
||||
hash_T hash;
|
||||
hashitem_T *hi;
|
||||
|
||||
b = alloc((unsigned)(cl + headcl + 2));
|
||||
b = xmalloc(cl + headcl + 2);
|
||||
mb_char2bytes(c, b);
|
||||
b[cl] = NUL;
|
||||
mb_char2bytes(headc, b + cl + 1);
|
||||
|
@ -97,7 +97,7 @@ char_u *vim_strsave_escaped_ext(char_u *string, char_u *esc_chars, int cc, int b
|
||||
++length; /* count a backslash */
|
||||
++length; /* count an ordinary char */
|
||||
}
|
||||
escaped_string = alloc(length);
|
||||
escaped_string = xmalloc(length);
|
||||
p2 = escaped_string;
|
||||
for (p = string; *p; p++) {
|
||||
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) {
|
||||
@ -158,7 +158,7 @@ char_u *vim_strsave_shellescape(char_u *string, bool do_special, bool do_newline
|
||||
}
|
||||
|
||||
/* Allocate memory for the result and fill it. */
|
||||
escaped_string = alloc(length);
|
||||
escaped_string = xmalloc(length);
|
||||
d = escaped_string;
|
||||
|
||||
/* add opening quote */
|
||||
@ -264,7 +264,7 @@ char_u *strup_save(char_u *orig)
|
||||
l = utf_ptr2len(p);
|
||||
newl = utf_char2len(uc);
|
||||
if (newl != l) {
|
||||
s = alloc((unsigned)STRLEN(res) + 1 + newl - l);
|
||||
s = xmalloc(STRLEN(res) + 1 + newl - l);
|
||||
memmove(s, res, p - res);
|
||||
STRCPY(s + (p - res) + newl, p + l);
|
||||
p = s + (p - res);
|
||||
|
@ -3924,7 +3924,6 @@ add_keyword (
|
||||
int conceal_char
|
||||
)
|
||||
{
|
||||
keyentry_T *kp;
|
||||
hashtab_T *ht;
|
||||
hashitem_T *hi;
|
||||
char_u *name_ic;
|
||||
@ -3936,7 +3935,7 @@ add_keyword (
|
||||
name_folded, MAXKEYWLEN + 1);
|
||||
else
|
||||
name_ic = name;
|
||||
kp = (keyentry_T *)alloc((int)(sizeof(keyentry_T) + STRLEN(name_ic)));
|
||||
keyentry_T *kp = xmalloc(sizeof(keyentry_T) + STRLEN(name_ic));
|
||||
STRCPY(kp->keyword, name_ic);
|
||||
kp->k_syn.id = id;
|
||||
kp->k_syn.inc_tag = current_syn_inc_tag;
|
||||
@ -4154,7 +4153,7 @@ static void syn_incl_toplevel(int id, int *flagsp)
|
||||
*flagsp |= HL_CONTAINED;
|
||||
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 = xmalloc(2 * sizeof(short));
|
||||
int tlg_id = curwin->w_s->b_syn_topgrp - SYNID_CLUSTER;
|
||||
|
||||
grp_list[0] = id;
|
||||
@ -4255,7 +4254,7 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing)
|
||||
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 = xmalloc(STRLEN(rest) + 1);
|
||||
syn_opt_arg.flags = 0;
|
||||
syn_opt_arg.keyword = TRUE;
|
||||
syn_opt_arg.sync_idx = NULL;
|
||||
@ -4556,7 +4555,7 @@ syn_cmd_region (
|
||||
* 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 = xmalloc(sizeof(struct pat_ptr));
|
||||
ppp->pp_next = pat_ptrs[item];
|
||||
pat_ptrs[item] = ppp;
|
||||
ppp->pp_synp = xcalloc(1, sizeof(synpat_T));
|
||||
@ -4782,7 +4781,7 @@ static void syn_combine_list(short **clstr1, short **clstr2, int list_op)
|
||||
clstr = NULL;
|
||||
break;
|
||||
}
|
||||
clstr = (short *)alloc((unsigned)((count + 1) * sizeof(short)));
|
||||
clstr = xmalloc((count + 1) * sizeof(short));
|
||||
clstr[count] = 0;
|
||||
}
|
||||
}
|
||||
@ -5231,7 +5230,7 @@ get_id_list (
|
||||
while (!ends_excmd(*p)) {
|
||||
for (end = p; *end && !vim_iswhite(*end) && *end != ','; ++end)
|
||||
;
|
||||
name = alloc((int)(end - p + 3)); /* leave room for "^$" */
|
||||
name = xmalloc((int)(end - p + 3)); /* leave room for "^$" */
|
||||
vim_strncpy(name + 1, p, end - p);
|
||||
if ( STRCMP(name + 1, "ALLBUT") == 0
|
||||
|| STRCMP(name + 1, "ALL") == 0
|
||||
@ -5325,7 +5324,7 @@ get_id_list (
|
||||
if (failed)
|
||||
break;
|
||||
if (round == 1) {
|
||||
retval = (short *)alloc((unsigned)((count + 1) * sizeof(short)));
|
||||
retval = xmalloc((count + 1) * sizeof(short));
|
||||
retval[count] = 0; /* zero means end of the list */
|
||||
total_count = count;
|
||||
}
|
||||
@ -5360,7 +5359,7 @@ static short *copy_id_list(short *list)
|
||||
for (count = 0; list[count]; ++count)
|
||||
;
|
||||
len = (count + 1) * sizeof(short);
|
||||
retval = (short *)alloc((unsigned)len);
|
||||
retval = xmalloc(len);
|
||||
memmove(retval, list, (size_t)len);
|
||||
|
||||
return retval;
|
||||
@ -5530,7 +5529,7 @@ void ex_ownsyntax(exarg_T *eap)
|
||||
char_u *new_value;
|
||||
|
||||
if (curwin->w_s == &curwin->w_buffer->b_s) {
|
||||
curwin->w_s = (synblock_T *)alloc(sizeof(synblock_T));
|
||||
curwin->w_s = xmalloc(sizeof(synblock_T));
|
||||
memset(curwin->w_s, 0, sizeof(synblock_T));
|
||||
curwin->w_p_spell = FALSE; /* No spell checking */
|
||||
clear_string_option(&curwin->w_s->b_p_spc);
|
||||
@ -6170,7 +6169,7 @@ int load_colors(char_u *name)
|
||||
return OK;
|
||||
|
||||
recursive = TRUE;
|
||||
buf = alloc((unsigned)(STRLEN(name) + 12));
|
||||
buf = xmalloc(STRLEN(name) + 12);
|
||||
sprintf((char *)buf, "colors/%s.vim", name);
|
||||
retval = source_runtime(buf, FALSE);
|
||||
free(buf);
|
||||
|
@ -679,8 +679,8 @@ do_tag (
|
||||
* window.
|
||||
*/
|
||||
|
||||
fname = alloc(MAXPATHL + 1);
|
||||
cmd = alloc(CMDBUFFSIZE + 1);
|
||||
fname = xmalloc(MAXPATHL + 1);
|
||||
cmd = xmalloc(CMDBUFFSIZE + 1);
|
||||
list = list_alloc();
|
||||
|
||||
for (i = 0; i < num_matches; ++i) {
|
||||
@ -1185,8 +1185,8 @@ find_tags (
|
||||
/*
|
||||
* Allocate memory for the buffers that are used
|
||||
*/
|
||||
lbuf = alloc(lbuf_size);
|
||||
tag_fname = alloc(MAXPATHL + 1);
|
||||
lbuf = xmalloc(lbuf_size);
|
||||
tag_fname = xmalloc(MAXPATHL + 1);
|
||||
for (mtt = 0; mtt < MT_COUNT; ++mtt)
|
||||
ga_init(&ga_match[mtt], (int)sizeof(struct match_found *), 100);
|
||||
|
||||
@ -1814,9 +1814,7 @@ parse_line:
|
||||
*/
|
||||
*tagp.tagname_end = NUL;
|
||||
len = (int)(tagp.tagname_end - tagp.tagname);
|
||||
mfp = (struct match_found *)
|
||||
alloc((int)sizeof(struct match_found) + len
|
||||
+ 10 + ML_EXTRA);
|
||||
mfp = xmalloc(sizeof(struct match_found) + len + 10 + ML_EXTRA);
|
||||
/* "len" includes the language and the NUL, but
|
||||
* not the priority. */
|
||||
mfp->len = len + ML_EXTRA + 1;
|
||||
@ -1844,8 +1842,7 @@ parse_line:
|
||||
|
||||
if (tagp.command + 2 < temp_end) {
|
||||
len = (int)(temp_end - tagp.command - 2);
|
||||
mfp = (struct match_found *)alloc(
|
||||
(int)sizeof(struct match_found) + len);
|
||||
mfp = xmalloc(sizeof(struct match_found) + len);
|
||||
mfp->len = len + 1; /* include the NUL */
|
||||
p = mfp->match;
|
||||
vim_strncpy(p, tagp.command + 2, len);
|
||||
@ -1854,8 +1851,7 @@ parse_line:
|
||||
get_it_again = FALSE;
|
||||
} else {
|
||||
len = (int)(tagp.tagname_end - tagp.tagname);
|
||||
mfp = (struct match_found *)alloc(
|
||||
(int)sizeof(struct match_found) + len);
|
||||
mfp = xmalloc(sizeof(struct match_found) + len);
|
||||
mfp->len = len + 1; /* include the NUL */
|
||||
p = mfp->match;
|
||||
vim_strncpy(p, tagp.tagname, len);
|
||||
@ -1872,8 +1868,7 @@ parse_line:
|
||||
*/
|
||||
len = (int)STRLEN(tag_fname)
|
||||
+ (int)STRLEN(lbuf) + 3;
|
||||
mfp = (struct match_found *)alloc(
|
||||
(int)sizeof(struct match_found) + len);
|
||||
mfp = xmalloc(sizeof(struct match_found) + len);
|
||||
mfp->len = len;
|
||||
p = mfp->match;
|
||||
p[0] = mtt;
|
||||
@ -2375,7 +2370,7 @@ jumpto_tag (
|
||||
char_u *full_fname = NULL;
|
||||
int old_KeyTyped = KeyTyped; /* getting the file may reset it */
|
||||
|
||||
pbuf = alloc(LSIZE);
|
||||
pbuf = xmalloc(LSIZE);
|
||||
|
||||
/* parse the match line into the tagp structure */
|
||||
if (parse_match(lbuf, &tagp) == FAIL) {
|
||||
@ -2642,7 +2637,7 @@ erret:
|
||||
* If "expand" is TRUE, expand wildcards in fname.
|
||||
* If 'tagrelative' option set, change fname (name of file containing tag)
|
||||
* according to tag_fname (name of tag file containing fname).
|
||||
* Returns a pointer to allocated memory (or NULL when out of memory).
|
||||
* Returns a pointer to allocated memory.
|
||||
*/
|
||||
static char_u *expand_tag_fname(char_u *fname, char_u *tag_fname, int expand)
|
||||
{
|
||||
@ -2666,7 +2661,7 @@ static char_u *expand_tag_fname(char_u *fname, char_u *tag_fname, int expand)
|
||||
if ((p_tr || curbuf->b_help)
|
||||
&& !vim_isAbsName(fname)
|
||||
&& (p = path_tail(tag_fname)) != tag_fname) {
|
||||
retval = alloc(MAXPATHL);
|
||||
retval = xmalloc(MAXPATHL);
|
||||
STRCPY(retval, tag_fname);
|
||||
vim_strncpy(retval + (p - tag_fname), fname,
|
||||
MAXPATHL - (p - tag_fname) - 1);
|
||||
@ -2805,7 +2800,6 @@ add_tag_field (
|
||||
char_u *end /* after the value; can be NULL */
|
||||
)
|
||||
{
|
||||
char_u *buf;
|
||||
int len = 0;
|
||||
int retval;
|
||||
|
||||
@ -2818,7 +2812,7 @@ add_tag_field (
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
buf = alloc(MAXPATHL);
|
||||
char_u *buf = xmalloc(MAXPATHL);
|
||||
if (start != NULL) {
|
||||
if (end == NULL) {
|
||||
end = start + STRLEN(start);
|
||||
|
@ -2983,8 +2983,7 @@ void add_termcode(char_u *name, char_u *string, int flags)
|
||||
*/
|
||||
if (tc_len == tc_max_len) {
|
||||
tc_max_len += 20;
|
||||
new_tc = (struct termcode *)alloc(
|
||||
(unsigned)(tc_max_len * sizeof(struct termcode)));
|
||||
new_tc = xmalloc(tc_max_len * sizeof(struct termcode));
|
||||
for (i = 0; i < tc_len; ++i)
|
||||
new_tc[i] = termcodes[i];
|
||||
free(termcodes);
|
||||
@ -4170,7 +4169,7 @@ replace_termcodes (
|
||||
* 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 = xmalloc(STRLEN(from) * 6 + 1);
|
||||
|
||||
src = from;
|
||||
|
||||
@ -4376,7 +4375,7 @@ void show_termcodes(void)
|
||||
|
||||
if (tc_len == 0) /* no terminal codes (must be GUI) */
|
||||
return;
|
||||
items = (int *)alloc((unsigned)(sizeof(int) * tc_len));
|
||||
items = xmalloc(sizeof(int) * tc_len);
|
||||
|
||||
/* Highlight title */
|
||||
MSG_PUTS_TITLE(_("\n--- Terminal keys ---"));
|
||||
|
@ -272,12 +272,10 @@ int vim_is_input_buf_empty(void)
|
||||
*/
|
||||
char_u *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));
|
||||
garray_T *gap = xmalloc(sizeof(garray_T));
|
||||
/* Add one to avoid a zero size. */
|
||||
gap->ga_data = alloc((unsigned)inbufcount + 1);
|
||||
gap->ga_data = xmalloc(inbufcount + 1);
|
||||
if (gap->ga_data != NULL)
|
||||
memmove(gap->ga_data, inbuf, (size_t)inbufcount);
|
||||
gap->ga_len = inbufcount;
|
||||
|
@ -5263,7 +5263,7 @@ int match_add(win_T *wp, char_u *grp, char_u *pat, int prio, int id)
|
||||
}
|
||||
|
||||
/* Build new match. */
|
||||
m = (matchitem_T *)alloc(sizeof(matchitem_T));
|
||||
m = xmalloc(sizeof(matchitem_T));
|
||||
m->id = id;
|
||||
m->priority = prio;
|
||||
m->pattern = vim_strsave(pat);
|
||||
|
Loading…
Reference in New Issue
Block a user