guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setgroups


From: Rob Browning
Subject: Re: setgroups
Date: Thu, 17 Apr 2003 22:34:13 -0500
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu)

address@hidden (Paul Jarc) writes:

> Ok, here's a patch for setgroups.  It's my first time writing Guile C
> code, so someone should check it carefully.  I used a vector argument
> just because that's what getgroups returns.

That sounds about right...

> +  ngroups = SCM_VECTOR_LENGTH (group_vec);
> +  size = ngroups * sizeof (GETGROUPS_T);
> +  groups = scm_malloc (size);
> +  for(i = ngroups; i >= 0; i--)
> +    groups [i] = SCM_INUM (SCM_VECTOR_REF (group_vec, i));
> +
> +  result = setgroups (ngroups, groups);
> +  free (groups);

I might add a 

     scm_remember_upto_here_1 (group_vec);

here just to be safe, but that might be overkill, depending on what
SCM_VECTOR_REF does.

> +  if (result < 0)
> +    SCM_SYSERROR;
> +  return SCM_UNSPECIFIED;
> +}

Overall, it looks good to me.

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]