1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-30 15:00:21 +02:00

GOOPS: Statically allocate the PORT class array.

* libguile/goops.c (scm_port_class): Statically allocate it.
  (create_port_classes): Don't use `scm_calloc ()'.

* libguile/goops.h (scm_port_class): Update declaration.

* libguile/ports.c (scm_make_port_type): When checking whether
  GOOPS is initialized, check whether the first element of
  SCM_PORT_CLASS is non-zero.
This commit is contained in:
Ludovic Courtès 2009-01-18 20:21:44 +01:00
parent 0953b54946
commit 63385df2fd
3 changed files with 8 additions and 8 deletions

View file

@ -152,7 +152,12 @@ SCM scm_class_protected_opaque, scm_class_protected_read_only;
SCM scm_class_scm; SCM scm_class_scm;
SCM scm_class_int, scm_class_float, scm_class_double; SCM scm_class_int, scm_class_float, scm_class_double;
SCM *scm_port_class = 0; /* Port classes. Allocate 3 times the maximum number of port types so that
input ports, output ports, and in/out ports can be stored at different
offsets. See `SCM_IN_PCLASS_INDEX' et al. */
SCM scm_port_class[3 * SCM_I_MAX_PORT_TYPE_COUNT];
/* SMOB classes. */
SCM scm_smob_class[SCM_I_MAX_SMOB_TYPE_COUNT]; SCM scm_smob_class[SCM_I_MAX_SMOB_TYPE_COUNT];
SCM scm_no_applicable_method; SCM scm_no_applicable_method;
@ -2741,11 +2746,6 @@ create_port_classes (void)
{ {
long i; long i;
/* Allocate 3 times the maximum number of port types so that input ports,
output ports, and in/out ports can be stored at different offsets. See
`SCM_IN_PCLASS_INDEX' et al. */
scm_port_class = scm_calloc (3 * SCM_I_MAX_PORT_TYPE_COUNT * sizeof (SCM));
for (i = 0; i < scm_numptob; ++i) for (i = 0; i < scm_numptob; ++i)
scm_make_port_classes (i, SCM_PTOBNAME (i)); scm_make_port_classes (i, SCM_PTOBNAME (i));
} }

View file

@ -168,7 +168,7 @@ SCM_API SCM scm_class_complex;
SCM_API SCM scm_class_integer; SCM_API SCM scm_class_integer;
SCM_API SCM scm_class_fraction; SCM_API SCM scm_class_fraction;
SCM_API SCM scm_class_unknown; SCM_API SCM scm_class_unknown;
SCM_API SCM *scm_port_class; SCM_API SCM scm_port_class[];
SCM_API SCM scm_smob_class[]; SCM_API SCM scm_smob_class[];
SCM_API SCM scm_class_top; SCM_API SCM scm_class_top;
SCM_API SCM scm_class_object; SCM_API SCM scm_class_object;

View file

@ -172,7 +172,7 @@ scm_make_port_type (char *name,
scm_memory_error ("scm_make_port_type"); scm_memory_error ("scm_make_port_type");
} }
/* Make a class object if Goops is present */ /* Make a class object if Goops is present */
if (scm_port_class) if (SCM_UNPACK (scm_port_class[0]) != 0)
scm_make_port_classes (scm_numptob - 1, SCM_PTOBNAME (scm_numptob - 1)); scm_make_port_classes (scm_numptob - 1, SCM_PTOBNAME (scm_numptob - 1));
return scm_tc7_port + (scm_numptob - 1) * 256; return scm_tc7_port + (scm_numptob - 1) * 256;
} }