diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-05-12 16:19:50 -0300 |
---|---|---|
committer | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-05-19 14:50:26 -0300 |
commit | e303a11ebfc352860cce73184ece692ab4d0f01c (patch) | |
tree | 67a3e4b7a8d6633149f9d22f3f51cd96498aacd4 /src/nvim/quickfix.c | |
parent | 7a830d945fb44a850b7cef65971f37a570a36e9e (diff) | |
download | rneovim-e303a11ebfc352860cce73184ece692ab4d0f01c.tar.gz rneovim-e303a11ebfc352860cce73184ece692ab4d0f01c.tar.bz2 rneovim-e303a11ebfc352860cce73184ece692ab4d0f01c.zip |
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()
Diffstat (limited to 'src/nvim/quickfix.c')
-rw-r--r-- | src/nvim/quickfix.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index a026cb46f5..269a33edcc 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -719,13 +719,10 @@ restofline: if (qfprev == NULL) goto error2; if (*errmsg && !multiignore) { - len = (int)STRLEN(qfprev->qf_text); - ptr = xmalloc(len + STRLEN(errmsg) + 2); - STRCPY(ptr, qfprev->qf_text); - free(qfprev->qf_text); - qfprev->qf_text = ptr; - *(ptr += len) = '\n'; - STRCPY(++ptr, errmsg); + size_t len = STRLEN(qfprev->qf_text); + qfprev->qf_text = xrealloc(qfprev->qf_text, len + STRLEN(errmsg) + 2); + qfprev->qf_text[len] = '\n'; + STRCPY(qfprev->qf_text + len + 1, errmsg); } if (qfprev->qf_nr == -1) qfprev->qf_nr = enr; |