aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2014-05-22 12:50:59 -0400
committerJustin M. Keyes <justinkz@gmail.com>2014-05-22 13:00:51 -0400
commite2e47803bdfd5fb40e3dbc9cdf798bb27d306c72 (patch)
tree6ff1b06b5d5fd6d3260f3a778c33cfaf03f0c295 /src/nvim/os
parent0aa8b5828cc0674894681841f40c3c05bfd2f07b (diff)
parente303a11ebfc352860cce73184ece692ab4d0f01c (diff)
downloadrneovim-e2e47803bdfd5fb40e3dbc9cdf798bb27d306c72.tar.gz
rneovim-e2e47803bdfd5fb40e3dbc9cdf798bb27d306c72.tar.bz2
rneovim-e2e47803bdfd5fb40e3dbc9cdf798bb27d306c72.zip
Merge #708 'Remove NULL/non-NULL tests after vim_str(n)save'
- replace alloc with xmalloc
Diffstat (limited to 'src/nvim/os')
-rw-r--r--src/nvim/os/fs.c6
-rw-r--r--src/nvim/os/users.c9
2 files changed, 6 insertions, 9 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 1b302098dd..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
@@ -28,10 +29,7 @@ int os_get_usernames(garray_T *users)
// pw->pw_name shouldn't be NULL but just in case...
if (pw->pw_name != NULL) {
ga_grow(users, 1);
- user = (char *)vim_strsave((char_u*)pw->pw_name);
- if (user == NULL) {
- return FAIL;
- }
+ user = xstrdup(pw->pw_name);
((char **)(users->ga_data))[users->ga_len++] = user;
}
}
@@ -79,8 +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
- char *user_directory = (char *)vim_strsave((char_u *)pw->pw_dir);
- return user_directory;
+ return xstrdup(pw->pw_dir);
}
#endif
return NULL;