From a80d7e86c1f088c5b68d8e8929cc72a0d9680f76 Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Thu, 8 May 2014 21:34:46 -0300 Subject: Remove NULL/non-NULL tests after calls to vim_str(n)save() --- src/nvim/os/users.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/nvim/os/users.c') diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c index 1b302098dd..e1faacb8ac 100644 --- a/src/nvim/os/users.c +++ b/src/nvim/os/users.c @@ -28,10 +28,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 +76,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 vim_strsave(pw->pw_dir); } #endif return NULL; -- cgit From 21784aeb005e78f04f4c1d398bc486be0a65248e Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Fri, 9 May 2014 03:30:26 -0300 Subject: Replace alloc() with xmalloc() and remove immediate OOM checks --- src/nvim/os/users.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/os/users.c') 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; -- cgit