From d3b9aa19f04e6be78afb8497e7808a3d42042bf2 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Thu, 26 Jan 2012 22:14:43 -0200 Subject: Better manage moreinfo hashes Have only one for the whole program and use per-module namespaces/prefixes so that each module can clear its own information easily. --- modules/computer/users.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'modules/computer/users.c') diff --git a/modules/computer/users.c b/modules/computer/users.c index e303ac6e..e8f891ac 100644 --- a/modules/computer/users.c +++ b/modules/computer/users.c @@ -22,12 +22,6 @@ gchar *users = NULL; -static gboolean -remove_users(gpointer key, gpointer value, gpointer data) -{ - return g_str_has_prefix(key, "USER"); -} - void scan_users_do(void) { @@ -38,7 +32,7 @@ scan_users_do(void) if (users) { g_free(users); - g_hash_table_foreach_remove(moreinfo, remove_users, NULL); + moreinfo_del_with_prefix("COMP:USER"); } users = g_strdup(""); @@ -54,11 +48,12 @@ scan_users_do(void) (gint) passwd_->pw_gid, passwd_->pw_dir, passwd_->pw_shell); - g_hash_table_insert(moreinfo, key, val); + moreinfo_add_with_prefix("COMP", key, val); strend(passwd_->pw_gecos, ','); users = h_strdup_cprintf("$%s$%s=%s\n", users, key, passwd_->pw_name, passwd_->pw_gecos); passwd_ = getpwent(); + g_free(key); } endpwent(); -- cgit v1.2.3