* libguile/dynl.c (free_string_pointers): Remove.
(scm_dynamic_args_call): Remove reference to `free_string_pointers ()'
and remove dynwind.
* libguile/posix.c (free_string_pointers): Remove.
(scm_execl, scm_execlp, scm_execle, scm_environ): Remove references
to `free_string_pointers ()'.
* libguile/simpos.c (free_string_pointers): Remove.
(scm_system_star): Remove reference to `free_string_pointers ()',
remove enclosing dynwind.
* libguile/strings.c (scm_i_allocate_string_pointers): Use
`scm_gc_malloc_pointerless ()' and `scm_gc_malloc ()'
instead of `scm_malloc ()' and `scm_to_locale_string ()',
so that the result is automatically GC'd when no longer
referenced. Remove unneeded dynwind.
(scm_i_free_string_pointers): Remove.
* libguile/strings.h (scm_i_free_string_pointers): Remove declaration.
/* dynl.c - dynamic linking
*
* Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002,
- * 2003, 2008 Free Software Foundation, Inc.
+ * 2003, 2008, 2009 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
}
#undef FUNC_NAME
-static void
-free_string_pointers (void *data)
-{
- scm_i_free_string_pointers ((char **)data);
-}
-
SCM_DEFINE (scm_dynamic_args_call, "dynamic-args-call", 3, 0, 0,
(SCM func, SCM dobj, SCM args),
"Call the C function indicated by @var{func} and @var{dobj},\n"
int result, argc;
char **argv;
- scm_dynwind_begin (0);
-
if (scm_is_string (func))
func = scm_dynamic_func (func, dobj);
fptr = (int (*) (int, char **)) scm_to_ulong (func);
argv = scm_i_allocate_string_pointers (args);
- scm_dynwind_unwind_handler (free_string_pointers, argv,
- SCM_F_WIND_EXPLICITLY);
for (argc = 0; argv[argc]; argc++)
;
result = (*fptr) (argc, argv);
- scm_dynwind_end ();
return scm_from_int (result);
}
#undef FUNC_NAME
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#undef FUNC_NAME
#endif /* HAVE_TCSETPGRP */
-static void
-free_string_pointers (void *data)
-{
- scm_i_free_string_pointers ((char **)data);
-}
-
SCM_DEFINE (scm_execl, "execl", 1, 0, 1,
(SCM filename, SCM args),
"Executes the file named by @var{path} as a new process image.\n"
scm_dynwind_free (exec_file);
exec_argv = scm_i_allocate_string_pointers (args);
- scm_dynwind_unwind_handler (free_string_pointers, exec_argv,
- SCM_F_WIND_EXPLICITLY);
execv (exec_file,
#ifdef __MINGW32__
scm_dynwind_free (exec_file);
exec_argv = scm_i_allocate_string_pointers (args);
- scm_dynwind_unwind_handler (free_string_pointers, exec_argv,
- SCM_F_WIND_EXPLICITLY);
execvp (exec_file,
#ifdef __MINGW32__
scm_dynwind_free (exec_file);
exec_argv = scm_i_allocate_string_pointers (args);
- scm_dynwind_unwind_handler (free_string_pointers, exec_argv,
- SCM_F_WIND_EXPLICITLY);
-
exec_env = scm_i_allocate_string_pointers (env);
- scm_dynwind_unwind_handler (free_string_pointers, exec_env,
- SCM_F_WIND_EXPLICITLY);
execve (exec_file,
#ifdef __MINGW32__
return scm_makfromstrs (-1, environ);
else
{
- char **new_environ;
-
- new_environ = scm_i_allocate_string_pointers (env);
- /* Free the old environment, except when called for the first
- * time.
- */
- {
- static int first = 1;
- if (!first)
- scm_i_free_string_pointers (environ);
- first = 0;
- }
- environ = new_environ;
+ environ = scm_i_allocate_string_pointers (env);
return SCM_UNSPECIFIED;
}
}
-/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2003, 2004 Free Software
+/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2003, 2004, 2009 Free Software
* Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
#ifdef HAVE_SYSTEM
#ifdef HAVE_WAITPID
-static void
-free_string_pointers (void *data)
-{
- scm_i_free_string_pointers ((char **)data);
-}
SCM_DEFINE (scm_system_star, "system*", 0, 0, 1,
(SCM args),
int pid;
char **execargv;
- scm_dynwind_begin (0);
-
/* allocate before fork */
execargv = scm_i_allocate_string_pointers (args);
- scm_dynwind_unwind_handler (free_string_pointers, execargv,
- SCM_F_WIND_EXPLICITLY);
/* make sure the child can't kill us (as per normal system call) */
sig_ign = scm_from_long ((unsigned long) SIG_IGN);
execvp (execargv[0], execargv);
SCM_SYSERROR;
/* not reached. */
- scm_dynwind_end ();
return SCM_BOOL_F;
}
else
scm_sigaction (sigint, SCM_CAR (oldint), SCM_CDR (oldint));
scm_sigaction (sigquit, SCM_CAR (oldquit), SCM_CDR (oldquit));
- scm_dynwind_end ();
return scm_from_int (status);
}
}
-/* Copyright (C) 1995,1996,1998,2000,2001, 2004, 2006, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,2000,2001, 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "libguile/strings.h"
#include "libguile/deprecation.h"
#include "libguile/validate.h"
-#include "libguile/dynwind.h"
\f
char **
scm_i_allocate_string_pointers (SCM list)
+#define FUNC_NAME "scm_i_allocate_string_pointers"
{
char **result;
int len = scm_ilength (list);
if (len < 0)
scm_wrong_type_arg_msg (NULL, 0, list, "proper list");
- scm_dynwind_begin (0);
-
- result = (char **) scm_malloc ((len + 1) * sizeof (char *));
+ result = scm_gc_malloc ((len + 1) * sizeof (char *),
+ "string pointers");
result[len] = NULL;
- scm_dynwind_unwind_handler (free, result, 0);
/* The list might be have been modified in another thread, so
we check LIST before each access.
*/
for (i = 0; i < len && scm_is_pair (list); i++)
{
- result[i] = scm_to_locale_string (SCM_CAR (list));
+ SCM str;
+ size_t len;
+
+ str = SCM_CAR (list);
+ len = scm_c_string_length (str);
+
+ result[i] = scm_gc_malloc_pointerless (len + 1, "string pointers");
+ memcpy (result[i], scm_i_string_chars (str), len);
+ result[i][len] = '\0';
+
list = SCM_CDR (list);
}
- scm_dynwind_end ();
return result;
}
-
-void
-scm_i_free_string_pointers (char **pointers)
-{
- int i;
-
- for (i = 0; pointers[i]; i++)
- free (pointers[i]);
- free (pointers);
-}
+#undef FUNC_NAME
void
scm_i_get_substring_spec (size_t len,
/* internal utility functions. */
SCM_INTERNAL char **scm_i_allocate_string_pointers (SCM list);
-SCM_INTERNAL void scm_i_free_string_pointers (char **pointers);
SCM_INTERNAL void scm_i_get_substring_spec (size_t len,
SCM start, size_t *cstart,
SCM end, size_t *cend);