diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-06-25 22:03:58 -0300 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-06-30 03:57:50 -0400 |
commit | 45e7814e6aa8aacd8772056863d13770d4e30b48 (patch) | |
tree | 4a5f6f66176393da31454756af9f375cab804f6c /src/nvim/os/users.c | |
parent | be3a4b6ca81c4e9dd3faa81dc01f53468ceed3ad (diff) | |
download | rneovim-45e7814e6aa8aacd8772056863d13770d4e30b48.tar.gz rneovim-45e7814e6aa8aacd8772056863d13770d4e30b48.tar.bz2 rneovim-45e7814e6aa8aacd8772056863d13770d4e30b48.zip |
Introduce GA_APPEND()
This macro is used to append an element to a growable array. It replaces this
common idiom:
ga_grow(&ga, 1);
((item_type *)ga.ga_data)[ga.ga_len] = item;
++ga.ga_len;
Diffstat (limited to 'src/nvim/os/users.c')
-rw-r--r-- | src/nvim/os/users.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c index e687ff3546..b6c013fa59 100644 --- a/src/nvim/os/users.c +++ b/src/nvim/os/users.c @@ -21,16 +21,13 @@ int os_get_usernames(garray_T *users) ga_init(users, sizeof(char *), 20); # if defined(HAVE_GETPWENT) && defined(HAVE_PWD_H) - char *user; struct passwd *pw; setpwent(); while ((pw = getpwent()) != NULL) { // pw->pw_name shouldn't be NULL but just in case... if (pw->pw_name != NULL) { - ga_grow(users, 1); - user = xstrdup(pw->pw_name); - ((char **)(users->ga_data))[users->ga_len++] = user; + GA_APPEND(char *, users, xstrdup(pw->pw_name)); } } endpwent(); |