From e303a11ebfc352860cce73184ece692ab4d0f01c Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Mon, 12 May 2014 16:19:50 -0300 Subject: 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() --- src/nvim/ex_getln.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index b507116ac3..278886cf5e 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -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, -- cgit