Hello, Miguel, I am glad to see you here again.
> 
> > > I have applied this patch to the CVS repository with a few changes
> > > (configure.in checks, plus made sure that the style matched the rest of
> > > the code).

I think this patch is reasonable.

BTW, I did not add ChangeLog entries for these getgrouplist() patches.

-- 
Regards,
Andrew V. Samoilov

________________________________________________________________
GET INTERNET ACCESS FROM BCS! http://www.bcs.zp.ua
Join BCS today! For your FREE webmail, visit: http://email.zp.ua/
src/ChangeLog:

        * utilunix.c (init_groups): Use glib memory allocation functions.

--- utilunix.c~ Mon Jan 31 09:28:11 2005
+++ utilunix.c  Mon Jan 31 15:44:24 2005
@@ -94,33 +94,32 @@ void init_groups (void)
 
 #ifdef HAVE_GETGROUPLIST
     {
-        gid_t *groups = NULL;
-        int ng = 1;
-        //struct group *grp;
-        gid_t *newgroups = NULL;
-        
-        groups = (gid_t *) malloc(ng * sizeof(gid_t));
+       gid_t *groups = g_new (gid_t, 1);
+       int ng = 1;
+       gid_t *newgroups = NULL;
 
-        if (getgrouplist(pwd->pw_name, pwd->pw_gid, groups, &ng) == -1) {
-                newgroups = (gid_t *) malloc(ng * sizeof(gid_t));
-                if (newgroups != NULL) {
-                        free (groups);
-                        groups = newgroups;
-                        getgrouplist (pwd->pw_name, pwd->pw_gid, groups, &ng);
-                } else
-                       ng = 1;
-        }
+       if (getgrouplist (pwd->pw_name, pwd->pw_gid, groups, &ng) == -1) {
+           newgroups = g_new (gid_t, ng);
+           if (newgroups != NULL) {
+               g_free (groups);
+               groups = newgroups;
+               getgrouplist (pwd->pw_name, pwd->pw_gid, groups, &ng);
+           } else
+               ng = 1;
+       }
 
-        for (i = 0; i < ng; i++) {
-            grp = getgrgid(groups[i]);
-            if (grp != NULL && !g_tree_lookup (current_user_gid, 
GUINT_TO_POINTER ((int) grp->gr_gid))) {
-                    g_tree_insert (current_user_gid,
-                                  GUINT_TO_POINTER ((int) grp->gr_gid),
-                                  g_strdup (grp->gr_name));
-            }
-        }
+       for (i = 0; i < ng; i++) {
+           grp = getgrgid (groups[i]);
+           if (grp != NULL
+               && !g_tree_lookup (current_user_gid,
+                                  GUINT_TO_POINTER ((int) grp->gr_gid))) {
+               g_tree_insert (current_user_gid,
+                              GUINT_TO_POINTER ((int) grp->gr_gid),
+                              g_strdup (grp->gr_name));
+           }
+       }
 
-       free(groups);
+       g_free (groups);
     }
 #else
     setgrent ();
_______________________________________________
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel

Reply via email to