mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
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.
This commit is contained in:
parent
231dd35616
commit
086063aa32
1 changed files with 10 additions and 26 deletions
|
@ -93,8 +93,6 @@
|
||||||
SCM_SYMBOL (scm_yes_sym, "yes");
|
SCM_SYMBOL (scm_yes_sym, "yes");
|
||||||
SCM_SYMBOL (scm_no_sym, "no");
|
SCM_SYMBOL (scm_no_sym, "no");
|
||||||
|
|
||||||
static SCM protected_objects = SCM_EOL;
|
|
||||||
|
|
||||||
/* Return a list of the current option setting. The format of an
|
/* Return a list of the current option setting. The format of an
|
||||||
* option setting is described in the above documentation. */
|
* option setting is described in the above documentation. */
|
||||||
static SCM
|
static SCM
|
||||||
|
@ -177,16 +175,17 @@ change_option_setting (SCM args, scm_t_option options[], const char *s,
|
||||||
int dry_run)
|
int dry_run)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
SCM locally_protected_args = args;
|
scm_t_bits *new_vals;
|
||||||
SCM malloc_obj = scm_malloc_obj (options_length (options) * sizeof (scm_t_bits));
|
|
||||||
scm_t_bits *flags = (scm_t_bits *) SCM_MALLOCDATA (malloc_obj);
|
new_vals = scm_gc_malloc (options_length (options) * sizeof (scm_t_bits),
|
||||||
|
"new-options");
|
||||||
|
|
||||||
for (i = 0; options[i].name; ++i)
|
for (i = 0; options[i].name; ++i)
|
||||||
{
|
{
|
||||||
if (options[i].type == SCM_OPTION_BOOLEAN)
|
if (options[i].type == SCM_OPTION_BOOLEAN)
|
||||||
flags[i] = 0;
|
new_vals[i] = 0;
|
||||||
else
|
else
|
||||||
flags[i] = options[i].val;
|
new_vals[i] = options[i].val;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!SCM_NULL_OR_NIL_P (args))
|
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)
|
switch (options[i].type)
|
||||||
{
|
{
|
||||||
case SCM_OPTION_BOOLEAN:
|
case SCM_OPTION_BOOLEAN:
|
||||||
flags[i] = 1;
|
new_vals[i] = 1;
|
||||||
break;
|
break;
|
||||||
case SCM_OPTION_INTEGER:
|
case SCM_OPTION_INTEGER:
|
||||||
args = SCM_CDR (args);
|
args = SCM_CDR (args);
|
||||||
flags[i] = scm_to_size_t (scm_car (args));
|
new_vals[i] = scm_to_size_t (scm_car (args));
|
||||||
break;
|
break;
|
||||||
case SCM_OPTION_SCM:
|
case SCM_OPTION_SCM:
|
||||||
args = SCM_CDR (args);
|
args = SCM_CDR (args);
|
||||||
flags[i] = SCM_UNPACK (scm_car (args));
|
new_vals[i] = SCM_UNPACK (scm_car (args));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
found = 1;
|
found = 1;
|
||||||
|
@ -226,20 +225,7 @@ change_option_setting (SCM args, scm_t_option options[], const char *s,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; options[i].name; ++i)
|
for (i = 0; options[i].name; ++i)
|
||||||
{
|
options[i].val = new_vals[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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -288,8 +274,6 @@ scm_init_opts (SCM (*func) (SCM), scm_t_option options[])
|
||||||
void
|
void
|
||||||
scm_init_options ()
|
scm_init_options ()
|
||||||
{
|
{
|
||||||
scm_gc_register_root (&protected_objects);
|
|
||||||
|
|
||||||
#include "libguile/options.x"
|
#include "libguile/options.x"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue