diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-04-01 01:41:39 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-06 22:54:59 -0300 |
commit | 13848aadbfed94a62505d4e349426990c75d2ae5 (patch) | |
tree | 664873759b05c4e50e879ef7630621dc023d3b56 /src/diff.c | |
parent | 6bbffee0a5b4239e3177812c5f5f20133aa60fe8 (diff) | |
download | rneovim-13848aadbfed94a62505d4e349426990c75d2ae5.tar.gz rneovim-13848aadbfed94a62505d4e349426990c75d2ae5.tar.bz2 rneovim-13848aadbfed94a62505d4e349426990c75d2ae5.zip |
Remove simpler cases of OOM error handling (after *alloc calls)
By simpler cases I mean cases where the OOM error is not expected to be handled
by the caller of the function that calls `alloc`, `lalloc`, `xrealloc`,
`xmalloc`, `alloc_clear`, and `lalloc_clear`.
These are the functions that:
- Do not return an allocated buffer
- Have OOM as the only error condition
I took note of the functions that expect the caller to handle the OOM error and
will go through them to check all the callers that may be handling OOM error in
future commits.
I'm ignoring eval.c and ex_.c in this series of commits. eval.c will soon be
obsolete and I will deal with ex_.c in later PRs.
Diffstat (limited to 'src/diff.c')
-rw-r--r-- | src/diff.c | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/src/diff.c b/src/diff.c index 0db4890cfe..eb1325b76e 100644 --- a/src/diff.c +++ b/src/diff.c @@ -825,31 +825,29 @@ static void diff_file(char_u *tmp_orig, char_u *tmp_new, char_u *tmp_diff) + STRLEN(p_srr) + 27; char_u *cmd = alloc((unsigned)len); - if (cmd != NULL) { - /* We don't want $DIFF_OPTIONS to get in the way. */ - if (os_getenv("DIFF_OPTIONS")) { - vim_setenv((char_u *)"DIFF_OPTIONS", (char_u *)""); - } - - /* Build the diff command and execute it. Always use -a, binary - * differences are of no use. Ignore errors, diff returns - * non-zero when differences have been found. */ - vim_snprintf((char *)cmd, len, "diff %s%s%s%s%s %s", - diff_a_works == FALSE ? "" : "-a ", - "", - (diff_flags & DIFF_IWHITE) ? "-b " : "", - (diff_flags & DIFF_ICASE) ? "-i " : "", - tmp_orig, tmp_new); - append_redir(cmd, (int)len, p_srr, tmp_diff); - block_autocmds(); /* Avoid ShellCmdPost stuff */ - (void)call_shell( - cmd, - kShellOptFilter | kShellOptSilent | kShellOptDoOut, - NULL - ); - unblock_autocmds(); - vim_free(cmd); - } + /* We don't want $DIFF_OPTIONS to get in the way. */ + if (os_getenv("DIFF_OPTIONS")) { + vim_setenv((char_u *)"DIFF_OPTIONS", (char_u *)""); + } + + /* Build the diff command and execute it. Always use -a, binary + * differences are of no use. Ignore errors, diff returns + * non-zero when differences have been found. */ + vim_snprintf((char *)cmd, len, "diff %s%s%s%s%s %s", + diff_a_works == FALSE ? "" : "-a ", + "", + (diff_flags & DIFF_IWHITE) ? "-b " : "", + (diff_flags & DIFF_ICASE) ? "-i " : "", + tmp_orig, tmp_new); + append_redir(cmd, (int)len, p_srr, tmp_diff); + block_autocmds(); /* Avoid ShellCmdPost stuff */ + (void)call_shell( + cmd, + kShellOptFilter | kShellOptSilent | kShellOptDoOut, + NULL + ); + unblock_autocmds(); + vim_free(cmd); } } @@ -902,9 +900,6 @@ void ex_diffpatch(exarg_T *eap) #endif // ifdef UNIX buf = alloc((unsigned)buflen); - if (buf == NULL) { - goto theend; - } #ifdef UNIX |