Remove OOM checks: expand_tag_fname() and tag_full_name()

This commit is contained in:
Felipe Oliveira Carvalho 2014-05-12 15:04:17 -03:00
parent 6ea2559f6c
commit 1d844dda46

View File

@ -557,10 +557,9 @@ do_tag (
/* Find out the actual file name. If it is long, truncate /* Find out the actual file name. If it is long, truncate
* it and put "..." in the middle */ * it and put "..." in the middle */
p = tag_full_fname(&tagp); p = tag_full_fname(&tagp);
if (p != NULL) { msg_puts_long_attr(p, hl_attr(HLF_D));
msg_puts_long_attr(p, hl_attr(HLF_D)); free(p);
free(p);
}
if (msg_col > 0) if (msg_col > 0)
msg_putchar('\n'); msg_putchar('\n');
if (got_int) if (got_int)
@ -699,8 +698,6 @@ do_tag (
/* Save the tag file name */ /* Save the tag file name */
p = tag_full_fname(&tagp); p = tag_full_fname(&tagp);
if (p == NULL)
continue;
vim_strncpy(fname, p, MAXPATHL); vim_strncpy(fname, p, MAXPATHL);
free(p); free(p);
@ -2321,19 +2318,13 @@ parse_match (
/* /*
* Find out the actual file name of a tag. Concatenate the tags file name * Find out the actual file name of a tag. Concatenate the tags file name
* with the matching tag file name. * with the matching tag file name.
* Returns an allocated string or NULL (out of memory). * Returns an allocated string.
*/ */
static char_u *tag_full_fname(tagptrs_T *tagp) static char_u *tag_full_fname(tagptrs_T *tagp)
{ {
char_u *fullname; int c = *tagp->fname_end;
int c; *tagp->fname_end = NUL;
char_u *fullname = expand_tag_fname(tagp->fname, tagp->tag_fname, FALSE);
{
c = *tagp->fname_end;
*tagp->fname_end = NUL;
}
fullname = expand_tag_fname(tagp->fname, tagp->tag_fname, FALSE);
*tagp->fname_end = c; *tagp->fname_end = c;
return fullname; return fullname;
@ -2406,8 +2397,6 @@ jumpto_tag (
* If 'tagrelative' option set, may change file name. * If 'tagrelative' option set, may change file name.
*/ */
fname = expand_tag_fname(fname, tagp.tag_fname, TRUE); fname = expand_tag_fname(fname, tagp.tag_fname, TRUE);
if (fname == NULL)
goto erret;
tofree_fname = fname; /* free() it later */ tofree_fname = fname; /* free() it later */
/* /*
@ -2642,7 +2631,6 @@ erret:
static char_u *expand_tag_fname(char_u *fname, char_u *tag_fname, int expand) static char_u *expand_tag_fname(char_u *fname, char_u *tag_fname, int expand)
{ {
char_u *p; char_u *p;
char_u *retval;
char_u *expanded_fname = NULL; char_u *expanded_fname = NULL;
expand_T xpc; expand_T xpc;
@ -2658,6 +2646,7 @@ static char_u *expand_tag_fname(char_u *fname, char_u *tag_fname, int expand)
fname = expanded_fname; fname = expanded_fname;
} }
char_u *retval;
if ((p_tr || curbuf->b_help) if ((p_tr || curbuf->b_help)
&& !vim_isAbsName(fname) && !vim_isAbsName(fname)
&& (p = path_tail(tag_fname)) != tag_fname) { && (p = path_tail(tag_fname)) != tag_fname) {
@ -2695,10 +2684,8 @@ static int test_for_current(char_u *fname, char_u *fname_end, char_u *tag_fname,
*fname_end = NUL; *fname_end = NUL;
} }
fullname = expand_tag_fname(fname, tag_fname, TRUE); fullname = expand_tag_fname(fname, tag_fname, TRUE);
if (fullname != NULL) { retval = (path_full_compare(fullname, buf_ffname, TRUE) & kEqualFiles);
retval = (path_full_compare(fullname, buf_ffname, TRUE) & kEqualFiles); free(fullname);
free(fullname);
}
*fname_end = c; *fname_end = c;
} }