aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/quickfix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/quickfix.c')
-rw-r--r--src/nvim/quickfix.c51
1 files changed, 20 insertions, 31 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 299a0a38db..269a33edcc 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -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) {
/*
@@ -719,13 +719,10 @@ restofline:
if (qfprev == NULL)
goto error2;
if (*errmsg && !multiignore) {
- len = (int)STRLEN(qfprev->qf_text);
- ptr = alloc((unsigned)(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;
@@ -856,7 +853,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,27 +918,20 @@ 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;
else
qfp->qf_fnum = qf_get_fnum(dir, fname);
- if ((qfp->qf_text = vim_strsave(mesg)) == NULL) {
- free(qfp);
- return FAIL;
- }
+ qfp->qf_text = vim_strsave(mesg);
qfp->qf_lnum = lnum;
qfp->qf_col = col;
qfp->qf_viscol = vis_col;
- if (pattern == NULL || *pattern == NUL)
+ if (pattern == NULL || *pattern == NUL) {
qfp->qf_pattern = NULL;
- else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL) {
- free(qfp->qf_text);
- free(qfp);
- return FAIL;
+ } else {
+ qfp->qf_pattern = vim_strsave(pattern);
}
qfp->qf_nr = nr;
if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */
@@ -1145,11 +1135,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;
@@ -2521,7 +2510,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)
@@ -2596,7 +2585,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);
@@ -2843,8 +2832,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. */
@@ -3112,7 +3101,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) {