1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

init port entry

This commit is contained in:
Han-Wen Nienhuys 2002-08-04 16:10:19 +00:00
parent 402788a938
commit 5f16b8973e
3 changed files with 10 additions and 10 deletions

View file

@ -1,5 +1,7 @@
2002-08-04 Han-Wen <hanwen@cs.uu.nl>
2002-08-04 Han-Wen Nienhuys <hanwen@cs.uu.nl>
* ports.c (scm_new_port_table_entry): init port entry to 0
completely.
* ports.c (scm_new_port_table_entry): change function from
scm_add_to_port_table. This prevents cells with null-pointers from

View file

@ -457,6 +457,7 @@ scm_new_port_table_entry (void)
#define FUNC_NAME "scm_new_port_table_entry"
{
scm_t_port *entry = (scm_t_port *) scm_gc_malloc (sizeof (scm_t_port), "port");
memset (entry, 0x0, sizeof (scm_t_port));
if (scm_port_table_size == scm_port_table_room)
{
@ -471,15 +472,10 @@ scm_new_port_table_entry (void)
entry->port = SCM_EOL;
entry->entry = scm_port_table_size;
entry->revealed = 0;
entry->stream = 0;
entry->file_name = SCM_BOOL_F;
entry->line_number = 0;
entry->column_number = 0;
entry->putback_buf = 0;
entry->putback_buf_size = 0;
entry->rw_active = SCM_PORT_NEITHER;
entry->rw_random = 0;
scm_port_table[scm_port_table_size] = entry;
scm_port_table_size++;

View file

@ -279,12 +279,14 @@ scm_mkstrport (SCM pos, SCM str, long modes, const char *caller)
scm_out_of_range (caller, pos);
if (!((modes & SCM_WRTNG) || (modes & SCM_RDNG)))
scm_misc_error ("scm_mkstrport", "port must read or write", SCM_EOL);
z = scm_cell (scm_tc16_strport, 0);
SCM_DEFER_INTS;
pt = scm_new_port_table_entry ();
SCM_SET_CELL_TYPE (z, scm_tc16_strport | modes);
z = scm_cell (scm_tc16_strport | modes, 0);
SCM_SETPTAB_ENTRY (z, pt);
pt->port = z;
SCM_SETSTREAM (z, SCM_UNPACK (str));
pt->write_buf = pt->read_buf = SCM_STRING_UCHARS (str);