diff --git a/libguile/goops.c b/libguile/goops.c index 61f81e6c5..1c61d10ae 100644 --- a/libguile/goops.c +++ b/libguile/goops.c @@ -2741,9 +2741,10 @@ create_port_classes (void) { long i; - scm_port_class = (SCM *) scm_malloc (3 * 256 * sizeof (SCM)); - for (i = 0; i < 3 * 256; ++i) - scm_port_class[i] = 0; + /* 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) scm_make_port_classes (i, SCM_PTOBNAME (i)); diff --git a/libguile/objects.h b/libguile/objects.h index 68996d2a0..9b2a0ed5a 100644 --- a/libguile/objects.h +++ b/libguile/objects.h @@ -3,7 +3,7 @@ #ifndef SCM_OBJECTS_H #define SCM_OBJECTS_H -/* Copyright (C) 1996,1999,2000,2001, 2003, 2006, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1996,1999,2000,2001, 2003, 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 @@ -171,9 +171,9 @@ typedef struct scm_effective_slot_definition { #define SCM_CMETHOD_ENV(cmethod) SCM_CAR (cmethod) /* Port classes */ -#define SCM_IN_PCLASS_INDEX 0x000 -#define SCM_OUT_PCLASS_INDEX 0x100 -#define SCM_INOUT_PCLASS_INDEX 0x200 +#define SCM_IN_PCLASS_INDEX 0 +#define SCM_OUT_PCLASS_INDEX SCM_I_MAX_PORT_TYPE_COUNT +#define SCM_INOUT_PCLASS_INDEX (2 * SCM_I_MAX_PORT_TYPE_COUNT) /* Plugin proxy classes for basic types. */ SCM_API SCM scm_metaclass_standard; diff --git a/libguile/ports.c b/libguile/ports.c index 964d4d113..c961ce3ae 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 2004, 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 @@ -134,7 +134,7 @@ scm_make_port_type (char *name, void (*write) (SCM port, const void *data, size_t size)) { char *tmp; - if (255 <= scm_numptob) + if (SCM_I_MAX_PORT_TYPE_COUNT - 1 <= scm_numptob) goto ptoberr; SCM_CRITICAL_SECTION_START; tmp = (char *) scm_gc_realloc ((char *) scm_ptobs, diff --git a/libguile/ports.h b/libguile/ports.h index 48bc643db..5e42a3468 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -3,7 +3,7 @@ #ifndef SCM_PORTS_H #define SCM_PORTS_H -/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 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 @@ -162,6 +162,9 @@ SCM_INTERNAL SCM scm_i_port_weak_hash; #define SCM_DECCOL(port) {if (SCM_COL (port) > 0) SCM_COL (port) -= 1;} #define SCM_TABCOL(port) {SCM_COL (port) += 8 - SCM_COL (port) % 8;} +/* Maximum number of port types. */ +#define SCM_I_MAX_PORT_TYPE_COUNT 256 + /* port-type description. */