aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-05-09 03:30:26 -0300
committerFelipe Oliveira Carvalho <felipekde@gmail.com>2014-05-19 14:50:23 -0300
commit21784aeb005e78f04f4c1d398bc486be0a65248e (patch)
tree5180a6de4bd033571e351d06b04419a3af768198 /src/nvim/os
parenta80d7e86c1f088c5b68d8e8929cc72a0d9680f76 (diff)
downloadrneovim-21784aeb005e78f04f4c1d398bc486be0a65248e.tar.gz
rneovim-21784aeb005e78f04f4c1d398bc486be0a65248e.tar.bz2
rneovim-21784aeb005e78f04f4c1d398bc486be0a65248e.zip
Replace alloc() with xmalloc() and remove immediate OOM checks
Diffstat (limited to 'src/nvim/os')
-rw-r--r--src/nvim/os/fs.c6
-rw-r--r--src/nvim/os/users.c3
2 files changed, 5 insertions, 4 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index 47bf2fd933..861e1b46c5 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -89,8 +89,8 @@ static bool is_executable_in_path(const char_u *name)
return false;
}
- int buf_len = STRLEN(name) + STRLEN(path) + 2;
- char_u *buf = alloc((unsigned)(buf_len));
+ size_t buf_len = STRLEN(name) + STRLEN(path) + 2;
+ char_u *buf = xmalloc(buf_len);
// Walk through all entries in $PATH to check if "name" exists there and
// is an executable file.
@@ -103,7 +103,7 @@ static bool is_executable_in_path(const char_u *name)
// Glue together the given directory from $PATH with name and save into
// buf.
vim_strncpy(buf, (char_u *) path, e - path);
- append_path((char *) buf, (const char *) name, buf_len);
+ append_path((char *) buf, (const char *) name, (int)buf_len);
if (is_executable(buf)) {
// Found our executable. Free buf and return.
diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c
index e1faacb8ac..707a2f5ee9 100644
--- a/src/nvim/os/users.c
+++ b/src/nvim/os/users.c
@@ -4,6 +4,7 @@
#include "nvim/os/os.h"
#include "nvim/garray.h"
+#include "nvim/memory.h"
#include "nvim/misc2.h"
#include "nvim/strings.h"
#ifdef HAVE_PWD_H
@@ -76,7 +77,7 @@ char *os_get_user_directory(const char *name)
pw = getpwnam(name);
if (pw != NULL) {
// save the string from the static passwd entry into malloced memory
- return vim_strsave(pw->pw_dir);
+ return xstrdup(pw->pw_dir);
}
#endif
return NULL;