summaryrefslogtreecommitdiff
path: root/libguile/options.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-11-18 10:59:13 +0100
committerAndy Wingo <wingo@pobox.com>2011-11-24 11:47:35 +0100
commit086063aa325ac465f6c914f43c6abe2a02cf9ed7 (patch)
tree8fb3328bbddbcd36b9bb5410bbedd1f0513f1e6c /libguile/options.c
parent231dd356162ba2ab1f67666fa40953fae538d107 (diff)
downloadguile-086063aa325ac465f6c914f43c6abe2a02cf9ed7.tar.gz
remove object protection from options.c
* libguile/options.c (change_option_setting, scm_init_options): Rely on the options being allocated in GC-able memory, as in static memory. Therefore there is no need for the gc-protect dance.
Diffstat (limited to 'libguile/options.c')
-rw-r--r--libguile/options.c36
1 files changed, 10 insertions, 26 deletions
diff --git a/libguile/options.c b/libguile/options.c
index 8eecd35f1..2d7e18f65 100644
--- a/libguile/options.c
+++ b/libguile/options.c
@@ -93,8 +93,6 @@
SCM_SYMBOL (scm_yes_sym, "yes");
SCM_SYMBOL (scm_no_sym, "no");
-static SCM protected_objects = SCM_EOL;
-
/* Return a list of the current option setting. The format of an
* option setting is described in the above documentation. */
static SCM
@@ -177,16 +175,17 @@ change_option_setting (SCM args, scm_t_option options[], const char *s,
int dry_run)
{
unsigned int i;
- SCM locally_protected_args = args;
- SCM malloc_obj = scm_malloc_obj (options_length (options) * sizeof (scm_t_bits));
- scm_t_bits *flags = (scm_t_bits *) SCM_MALLOCDATA (malloc_obj);
+ scm_t_bits *new_vals;
+
+ new_vals = scm_gc_malloc (options_length (options) * sizeof (scm_t_bits),
+ "new-options");
for (i = 0; options[i].name; ++i)
{
if (options[i].type == SCM_OPTION_BOOLEAN)
- flags[i] = 0;
+ new_vals[i] = 0;
else
- flags[i] = options[i].val;
+ new_vals[i] = options[i].val;
}
while (!SCM_NULL_OR_NIL_P (args))
@@ -201,15 +200,15 @@ change_option_setting (SCM args, scm_t_option options[], const char *s,
switch (options[i].type)
{
case SCM_OPTION_BOOLEAN:
- flags[i] = 1;
+ new_vals[i] = 1;
break;
case SCM_OPTION_INTEGER:
args = SCM_CDR (args);
- flags[i] = scm_to_size_t (scm_car (args));
+ new_vals[i] = scm_to_size_t (scm_car (args));
break;
case SCM_OPTION_SCM:
args = SCM_CDR (args);
- flags[i] = SCM_UNPACK (scm_car (args));
+ new_vals[i] = SCM_UNPACK (scm_car (args));
break;
}
found = 1;
@@ -226,20 +225,7 @@ change_option_setting (SCM args, scm_t_option options[], const char *s,
return;
for (i = 0; options[i].name; ++i)
- {
- if (options[i].type == SCM_OPTION_SCM)
- {
- SCM old = SCM_PACK (options[i].val);
- SCM new = SCM_PACK (flags[i]);
- if (SCM_HEAP_OBJECT_P (old))
- protected_objects = scm_delq1_x (old, protected_objects);
- if (SCM_HEAP_OBJECT_P (new))
- protected_objects = scm_cons (new, protected_objects);
- }
- options[i].val = flags[i];
- }
-
- scm_remember_upto_here_2 (locally_protected_args, malloc_obj);
+ options[i].val = new_vals[i];
}
@@ -288,8 +274,6 @@ scm_init_opts (SCM (*func) (SCM), scm_t_option options[])
void
scm_init_options ()
{
- scm_gc_register_root (&protected_objects);
-
#include "libguile/options.x"
}