aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.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/os_unix.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/os_unix.c')
-rw-r--r--src/os_unix.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 5da3c6fb3f..06b4e30ffd 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -1143,11 +1143,6 @@ int flags; /* EW_* flags */
}
}
command = alloc(len);
- if (command == NULL) {
- /* out of memory */
- vim_free(tempname);
- return FAIL;
- }
/*
* Build the shell command:
@@ -1297,13 +1292,6 @@ int flags; /* EW_* flags */
len = ftell(fd); /* get size of temp file */
fseek(fd, 0L, SEEK_SET);
buffer = alloc(len + 1);
- if (buffer == NULL) {
- /* out of memory */
- mch_remove(tempname);
- vim_free(tempname);
- fclose(fd);
- return FAIL;
- }
i = fread((char *)buffer, 1, len, fd);
fclose(fd);
mch_remove(tempname);
@@ -1388,11 +1376,6 @@ int flags; /* EW_* flags */
}
*num_file = i;
*file = (char_u **)alloc(sizeof(char_u *) * i);
- if (*file == NULL) {
- /* out of memory */
- vim_free(buffer);
- return FAIL;
- }
/*
* Isolate the individual file names.
@@ -1437,12 +1420,10 @@ int flags; /* EW_* flags */
continue;
p = alloc((unsigned)(STRLEN((*file)[i]) + 1 + dir));
- if (p) {
- STRCPY(p, (*file)[i]);
- if (dir)
- add_pathsep(p); /* add '/' to a directory name */
- (*file)[j++] = p;
- }
+ STRCPY(p, (*file)[i]);
+ if (dir)
+ add_pathsep(p); /* add '/' to a directory name */
+ (*file)[j++] = p;
}
vim_free(buffer);
*num_file = j;