aboutsummaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-04-01 01:41:39 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-06 22:54:59 -0300
commit13848aadbfed94a62505d4e349426990c75d2ae5 (patch)
tree664873759b05c4e50e879ef7630621dc023d3b56 /src/buffer.c
parent6bbffee0a5b4239e3177812c5f5f20133aa60fe8 (diff)
downloadrneovim-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/buffer.c')
-rw-r--r--src/buffer.c53
1 files changed, 18 insertions, 35 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 27f3f5cab6..b104abfa40 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1369,10 +1369,6 @@ buflist_new (
}
if (buf != curbuf || curbuf == NULL) {
buf = (buf_T *)alloc_clear((unsigned)sizeof(buf_T));
- if (buf == NULL) {
- vim_free(ffname);
- return NULL;
- }
/* init b: variables */
buf->b_vars = dict_alloc();
if (buf->b_vars == NULL) {
@@ -1391,8 +1387,7 @@ buflist_new (
clear_wininfo(buf);
buf->b_wininfo = (wininfo_T *)alloc_clear((unsigned)sizeof(wininfo_T));
- if ((ffname != NULL && (buf->b_ffname == NULL || buf->b_sfname == NULL))
- || buf->b_wininfo == NULL) {
+ if (ffname != NULL && (buf->b_ffname == NULL || buf->b_sfname == NULL)) {
vim_free(buf->b_ffname);
buf->b_ffname = NULL;
vim_free(buf->b_sfname);
@@ -1837,8 +1832,6 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
/* Make a copy of "pat" and change "^" to "\(^\|[\/]\)". */
if (*pat == '^') {
patc = alloc((unsigned)STRLEN(pat) + 11);
- if (patc == NULL)
- return FAIL;
STRCPY(patc, "\\(^\\|[\\/]\\)");
STRCPY(patc + 11, pat + 1);
} else
@@ -2001,8 +1994,6 @@ static void buflist_setfpos(buf_T *buf, win_T *win, linenr_T lnum, colnr_T col,
if (wip == NULL) {
/* allocate a new entry */
wip = (wininfo_T *)alloc_clear((unsigned)sizeof(wininfo_T));
- if (wip == NULL)
- return;
wip->wi_win = win;
if (lnum == 0) /* set lnum even when it's 0 */
lnum = 1;
@@ -2523,8 +2514,6 @@ fileinfo (
size_t len;
buffer = alloc(IOSIZE);
- if (buffer == NULL)
- return;
if (fullname > 1) { /* 2 CTRL-G: include buffer number */
vim_snprintf((char *)buffer, IOSIZE, "buf %d: ", curbuf->b_fnum);
@@ -3700,8 +3689,6 @@ do_arg_all (
opened_len = ARGCOUNT;
opened = alloc_clear((unsigned)opened_len);
- if (opened == NULL)
- return;
/* Autocommands may do anything to the argument list. Make sure it's not
* freed while we are working here by "locking" it. We still have to
@@ -4292,8 +4279,6 @@ void write_viminfo_bufferlist(FILE *fp)
/* Allocate room for the file name, lnum and col. */
#define LINE_BUF_LEN (MAXPATHL + 40)
line = alloc(LINE_BUF_LEN);
- if (line == NULL)
- return;
FOR_ALL_TAB_WINDOWS(tp, win)
set_last_cursor(win);
@@ -4380,26 +4365,24 @@ static void insert_sign(
signlist_T *newsign;
newsign = (signlist_T *)lalloc((long_u)sizeof(signlist_T), FALSE);
- if (newsign != NULL) {
- newsign->id = id;
- newsign->lnum = lnum;
- newsign->typenr = typenr;
- newsign->next = next;
-
- if (prev == NULL) {
- /* When adding first sign need to redraw the windows to create the
- * column for signs. */
- if (buf->b_signlist == NULL) {
- redraw_buf_later(buf, NOT_VALID);
- changed_cline_bef_curs();
- }
-
- /* first sign in signlist */
- buf->b_signlist = newsign;
- }
- else {
- prev->next = newsign;
+ newsign->id = id;
+ newsign->lnum = lnum;
+ newsign->typenr = typenr;
+ newsign->next = next;
+
+ if (prev == NULL) {
+ /* When adding first sign need to redraw the windows to create the
+ * column for signs. */
+ if (buf->b_signlist == NULL) {
+ redraw_buf_later(buf, NOT_VALID);
+ changed_cline_bef_curs();
}
+
+ /* first sign in signlist */
+ buf->b_signlist = newsign;
+ }
+ else {
+ prev->next = newsign;
}
}