mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
Use realloc instead of vim_realloc
This commit is contained in:
parent
580ababcb5
commit
f8432ef127
@ -12015,7 +12015,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv)
|
||||
/* Change "prev" buffer to be the right size. This way
|
||||
* the bytes are only copied once, and very long lines are
|
||||
* allocated only once. */
|
||||
if ((s = vim_realloc(prev, prevlen + len + 1)) != NULL) {
|
||||
if ((s = realloc(prev, prevlen + len + 1)) != NULL) {
|
||||
memmove(s + prevlen, start, len);
|
||||
s[prevlen + len] = NUL;
|
||||
prev = NULL; /* the list will own the string */
|
||||
@ -12100,7 +12100,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv)
|
||||
prevsize = grow50pc > growmin ? grow50pc : growmin;
|
||||
}
|
||||
newprev = prev == NULL ? alloc(prevsize)
|
||||
: vim_realloc(prev, prevsize);
|
||||
: realloc(prev, prevsize);
|
||||
if (newprev == NULL) {
|
||||
do_outofmem_msg((long_u)prevsize);
|
||||
failed = TRUE;
|
||||
|
@ -386,7 +386,7 @@ vim_findfile_init (
|
||||
void *ptr;
|
||||
|
||||
helper = walker;
|
||||
ptr = vim_realloc(search_ctx->ffsc_stopdirs_v,
|
||||
ptr = realloc(search_ctx->ffsc_stopdirs_v,
|
||||
(dircount + 1) * sizeof(char_u *));
|
||||
if (ptr)
|
||||
search_ctx->ffsc_stopdirs_v = ptr;
|
||||
|
@ -73,7 +73,7 @@ int ga_grow(garray_T *gap, int n)
|
||||
new_len = gap->ga_itemsize * (gap->ga_len + n);
|
||||
pp = (gap->ga_data == NULL)
|
||||
? alloc((unsigned)new_len)
|
||||
: vim_realloc(gap->ga_data, new_len);
|
||||
: realloc(gap->ga_data, new_len);
|
||||
|
||||
if (pp == NULL) {
|
||||
return FAIL;
|
||||
|
@ -1330,7 +1330,7 @@ static int cs_insert_filelist(char *fname, char *ppath, char *flags, struct stat
|
||||
} else {
|
||||
/* Reallocate space for more connections. */
|
||||
csinfo_size *= 2;
|
||||
csinfo = vim_realloc(csinfo, sizeof(csinfo_T)*csinfo_size);
|
||||
csinfo = realloc(csinfo, sizeof(csinfo_T)*csinfo_size);
|
||||
}
|
||||
if (csinfo == NULL)
|
||||
return -1;
|
||||
@ -1870,7 +1870,7 @@ static void cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
|
||||
/* hopefully 'num' (num of matches) will be less than 10^16 */
|
||||
newsize = (int)(strlen(csfmt_str) + 16 + strlen(lno));
|
||||
if (bufsize < newsize) {
|
||||
buf = (char *)vim_realloc(buf, newsize);
|
||||
buf = (char *)realloc(buf, newsize);
|
||||
if (buf == NULL)
|
||||
bufsize = 0;
|
||||
else
|
||||
@ -1891,7 +1891,7 @@ static void cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
|
||||
newsize = (int)(strlen(context) + strlen(cntxformat));
|
||||
|
||||
if (bufsize < newsize) {
|
||||
buf = (char *)vim_realloc(buf, newsize);
|
||||
buf = (char *)realloc(buf, newsize);
|
||||
if (buf == NULL)
|
||||
bufsize = 0;
|
||||
else
|
||||
|
@ -4371,7 +4371,7 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype)
|
||||
if (buf->b_ml.ml_usedchunks + 1 >= buf->b_ml.ml_numchunks) {
|
||||
buf->b_ml.ml_numchunks = buf->b_ml.ml_numchunks * 3 / 2;
|
||||
buf->b_ml.ml_chunksize = (chunksize_T *)
|
||||
vim_realloc(buf->b_ml.ml_chunksize,
|
||||
realloc(buf->b_ml.ml_chunksize,
|
||||
sizeof(chunksize_T) * buf->b_ml.ml_numchunks);
|
||||
if (buf->b_ml.ml_chunksize == NULL) {
|
||||
/* Hmmmm, Give up on offset for this buffer */
|
||||
|
@ -2417,7 +2417,7 @@ int get_keystroke(void)
|
||||
/* Need some more space. This might happen when receiving a long
|
||||
* escape sequence. */
|
||||
buflen += 100;
|
||||
buf = vim_realloc(buf, buflen);
|
||||
buf = realloc(buf, buflen);
|
||||
maxlen = (buflen - 6 - len) / 3;
|
||||
}
|
||||
if (buf == NULL) {
|
||||
|
@ -4496,7 +4496,7 @@ static void nv_ident(cmdarg_T *cap)
|
||||
vim_free(buf);
|
||||
return;
|
||||
}
|
||||
newbuf = (char_u *)vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);
|
||||
newbuf = (char_u *)realloc(buf, STRLEN(buf) + STRLEN(p) + 1);
|
||||
if (newbuf == NULL) {
|
||||
vim_free(buf);
|
||||
vim_free(p);
|
||||
|
@ -3963,7 +3963,7 @@ skip_add:
|
||||
subs = &temp_subs;
|
||||
}
|
||||
|
||||
l->t = vim_realloc(l->t, newlen * sizeof(nfa_thread_T));
|
||||
l->t = realloc(l->t, newlen * sizeof(nfa_thread_T));
|
||||
l->len = newlen;
|
||||
}
|
||||
|
||||
|
@ -1387,9 +1387,6 @@ typedef int VimClipboard; /* This is required for the prototypes. */
|
||||
/* stop using fastcall for Borland */
|
||||
|
||||
|
||||
/* Note: a NULL argument for vim_realloc() is not portable, don't use it. */
|
||||
#define vim_realloc(ptr, size) realloc((ptr), (size))
|
||||
|
||||
/*
|
||||
* The following macros stop display/event loop nesting at the wrong time.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user