Remove OOM checks: suggested changes in review

- Replace a vim_strsave/free pair with xrealloc
 - Use xmallocz() in some places
 - Use xrealloc() and forget about the NULL pointer case
 - Remove invalid comment
 - Remove unnecessary checks
 - Replace a complicated xmalloc/STRCPY/free code chunk code with xrealloc()
 - Replace a vim_strsave/free code chunk with xrealloc()
This commit is contained in:
Felipe Oliveira Carvalho
2014-05-12 16:19:50 -03:00
parent 7a830d945f
commit e303a11ebf
5 changed files with 14 additions and 33 deletions

View File

@@ -1986,7 +1986,7 @@ static void alloc_cmdbuff(int len)
else
len += 20;
ccline.cmdbuff = xmalloc(len); /* caller should check for out-of-memory */
ccline.cmdbuff = xmalloc(len);
ccline.cmdbufflen = len;
}
@@ -2179,10 +2179,7 @@ void put_on_cmdline(char_u *str, int len, int redraw)
if (len < 0)
len = (int)STRLEN(str);
/* Check if ccline.cmdbuff needs to be longer */
if (ccline.cmdlen + len + 1 >= ccline.cmdbufflen) {
realloc_cmdbuff(ccline.cmdlen + len + 1);
}
realloc_cmdbuff(ccline.cmdlen + len + 1);
if (!ccline.overstrike) {
memmove(ccline.cmdbuff + ccline.cmdpos + len,