/[guile]/guile/guile-core/libguile/posix.c
ViewVC logotype

Diff of /guile/guile-core/libguile/posix.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.99 by ossau, Tue Jan 22 23:31:39 2002 UTC revision 1.100 by mvo, Mon Feb 11 18:06:49 2002 UTC
# Line 232  SCM_DEFINE (scm_getgroups, "getgroups", Line 232  SCM_DEFINE (scm_getgroups, "getgroups",
232      SCM_SYSERROR;      SCM_SYSERROR;
233    
234    size = ngroups * sizeof (GETGROUPS_T);    size = ngroups * sizeof (GETGROUPS_T);
235    groups = scm_must_malloc (size, FUNC_NAME);    groups = scm_malloc (size);
236    getgroups (ngroups, groups);    getgroups (ngroups, groups);
237    
238    ans = scm_c_make_vector (ngroups, SCM_UNDEFINED);    ans = scm_c_make_vector (ngroups, SCM_UNDEFINED);
239    while (--ngroups >= 0)    while (--ngroups >= 0)
240      SCM_VELTS (ans) [ngroups] = SCM_MAKINUM (groups [ngroups]);      SCM_VELTS (ans) [ngroups] = SCM_MAKINUM (groups [ngroups]);
241    
242    scm_must_free (groups);    free (groups);
   scm_done_free (size);  
   
243    return ans;    return ans;
244  }  }
245  #undef FUNC_NAME    #undef FUNC_NAME  
# Line 842  scm_convert_exec_args (SCM args, int arg Line 840  scm_convert_exec_args (SCM args, int arg
840    
841    argc = scm_ilength (args);    argc = scm_ilength (args);
842    SCM_ASSERT (argc >= 0, args, argn, subr);    SCM_ASSERT (argc >= 0, args, argn, subr);
843    argv = (char **) scm_must_malloc ((argc + 1) * sizeof (char *), subr);    argv = (char **) scm_malloc ((argc + 1) * sizeof (char *));
844    for (i = 0; !SCM_NULLP (args); args = SCM_CDR (args), ++i)    for (i = 0; !SCM_NULLP (args); args = SCM_CDR (args), ++i)
845      {      {
846        SCM arg = SCM_CAR (args);        SCM arg = SCM_CAR (args);
# Line 853  scm_convert_exec_args (SCM args, int arg Line 851  scm_convert_exec_args (SCM args, int arg
851        SCM_ASSERT (SCM_STRINGP (arg), args, argn, subr);        SCM_ASSERT (SCM_STRINGP (arg), args, argn, subr);
852        len = SCM_STRING_LENGTH (arg);        len = SCM_STRING_LENGTH (arg);
853        src = SCM_STRING_CHARS (arg);        src = SCM_STRING_CHARS (arg);
854        dst = (char *) scm_must_malloc (len + 1, subr);        dst = (char *) scm_malloc (len + 1);
855        memcpy (dst, src, len);        memcpy (dst, src, len);
856        dst[len] = 0;        dst[len] = 0;
857        argv[i] = dst;        argv[i] = dst;
# Line 1635  SCM_DEFINE (scm_gethostname, "gethostnam Line 1633  SCM_DEFINE (scm_gethostname, "gethostnam
1633    /* 256 is for Solaris, under Linux ENAMETOOLONG is returned if not    /* 256 is for Solaris, under Linux ENAMETOOLONG is returned if not
1634       large enough.  */       large enough.  */
1635    int len = 256, res;    int len = 256, res;
1636    char *p = scm_must_malloc (len, "gethostname");    char *p = scm_malloc (len);
1637    SCM name;    SCM name;
1638    
1639    res = gethostname (p, len);    res = gethostname (p, len);
1640    while (res == -1 && errno == ENAMETOOLONG)    while (res == -1 && errno == ENAMETOOLONG)
1641      {      {
1642        p = scm_must_realloc (p, len, len * 2, "gethostname");        p = scm_realloc (p, len * 2);
1643        len *= 2;        len *= 2;
1644        res = gethostname (p, len);        res = gethostname (p, len);
1645      }      }
1646    if (res == -1)    if (res == -1)
1647      {      {
1648        scm_must_free (p);        free (p);
1649        SCM_SYSERROR;        SCM_SYSERROR;
1650      }      }
1651    name = scm_makfrom0str (p);    name = scm_makfrom0str (p);
1652    scm_must_free (p);    free (p);
1653    return name;    return name;
1654  }  }
1655  #undef FUNC_NAME  #undef FUNC_NAME

Legend:
Removed from v.1.99  
changed lines
  Added in v.1.100

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26