/[guile]/guile/guile-core/libguile/ports.c
ViewVC logotype

Diff of /guile/guile-core/libguile/ports.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.161 by mvo, Sun Nov 25 15:21:06 2001 UTC revision 1.162 by mvo, Mon Feb 11 18:06:49 2002 UTC
# Line 124  end_input_default (SCM port SCM_UNUSED, Line 124  end_input_default (SCM port SCM_UNUSED,
124  {  {
125  }  }
126    
127    static size_t
128    scm_port_free0 (SCM port)
129    {
130      return 0;
131    }
132    
133  scm_t_bits  scm_t_bits
134  scm_make_port_type (char *name,  scm_make_port_type (char *name,
135                      int (*fill_input) (SCM port),                      int (*fill_input) (SCM port),
# Line 142  scm_make_port_type (char *name, Line 148  scm_make_port_type (char *name,
148    
149        scm_ptobs[scm_numptob].name = name;        scm_ptobs[scm_numptob].name = name;
150        scm_ptobs[scm_numptob].mark = 0;        scm_ptobs[scm_numptob].mark = 0;
151        scm_ptobs[scm_numptob].free = scm_free0;        scm_ptobs[scm_numptob].free = scm_port_free0;
152        scm_ptobs[scm_numptob].print = scm_port_print;        scm_ptobs[scm_numptob].print = scm_port_print;
153        scm_ptobs[scm_numptob].equalp = 0;        scm_ptobs[scm_numptob].equalp = 0;
154        scm_ptobs[scm_numptob].close = 0;        scm_ptobs[scm_numptob].close = 0;
# Line 455  scm_add_to_port_table (SCM port) Line 461  scm_add_to_port_table (SCM port)
461    
462    if (scm_port_table_size == scm_port_table_room)    if (scm_port_table_size == scm_port_table_room)
463      {      {
464        /* initial malloc is in gc.c.  this doesn't use scm_must_malloc etc.,        /* initial malloc is in gc.c.  this doesn't use scm_gc_malloc etc.,
465           since it can never be freed during gc.  */           since it can never be freed during gc.  */
466        void *newt = realloc ((char *) scm_port_table,        void *newt = scm_realloc ((char *) scm_port_table,
467                              (size_t) (sizeof (scm_t_port *)                                  (size_t) (sizeof (scm_t_port *)
468                                           * scm_port_table_room * 2));                                            * scm_port_table_room * 2));
       if (newt == NULL)  
         scm_memory_error ("scm_add_to_port_table");  
469        scm_port_table = (scm_t_port **) newt;        scm_port_table = (scm_t_port **) newt;
470        scm_port_table_room *= 2;        scm_port_table_room *= 2;
471      }      }
472    entry = (scm_t_port *) scm_must_malloc (sizeof (scm_t_port), FUNC_NAME);    entry = (scm_t_port *) scm_gc_malloc (sizeof (scm_t_port), "port");
473    
474    entry->port = port;    entry->port = port;
475    entry->entry = scm_port_table_size;    entry->entry = scm_port_table_size;
# Line 498  scm_remove_from_port_table (SCM port) Line 502  scm_remove_from_port_table (SCM port)
502    if (i >= scm_port_table_size)    if (i >= scm_port_table_size)
503      SCM_MISC_ERROR ("Port not in table: ~S", scm_list_1 (port));      SCM_MISC_ERROR ("Port not in table: ~S", scm_list_1 (port));
504    if (p->putback_buf)    if (p->putback_buf)
505      scm_must_free (p->putback_buf);      scm_gc_free (p->putback_buf, p->putback_buf_size, "putback buffer");
506    scm_must_free (p);    scm_gc_free (p, sizeof (scm_t_port), "port");
507    /* Since we have just freed slot i we can shrink the table by moving    /* Since we have just freed slot i we can shrink the table by moving
508       the last entry to that slot... */       the last entry to that slot... */
509    if (i < scm_port_table_size - 1)    if (i < scm_port_table_size - 1)
# Line 1098  scm_ungetc (int c, SCM port) Line 1102  scm_ungetc (int c, SCM port)
1102          {          {
1103            size_t new_size = pt->read_buf_size * 2;            size_t new_size = pt->read_buf_size * 2;
1104            unsigned char *tmp = (unsigned char *)            unsigned char *tmp = (unsigned char *)
1105              scm_must_realloc (pt->putback_buf, pt->read_buf_size, new_size,              scm_gc_realloc (pt->putback_buf, pt->read_buf_size, new_size,
1106                                FUNC_NAME);                              "putback buffer");
1107    
1108            pt->read_pos = pt->read_buf = pt->putback_buf = tmp;            pt->read_pos = pt->read_buf = pt->putback_buf = tmp;
1109            pt->read_end = pt->read_buf + pt->read_buf_size;            pt->read_end = pt->read_buf + pt->read_buf_size;
# Line 1125  scm_ungetc (int c, SCM port) Line 1129  scm_ungetc (int c, SCM port)
1129        if (pt->putback_buf == NULL)        if (pt->putback_buf == NULL)
1130          {          {
1131            pt->putback_buf            pt->putback_buf
1132              = (unsigned char *) scm_must_malloc (SCM_INITIAL_PUTBACK_BUF_SIZE,              = (unsigned char *) scm_gc_malloc (SCM_INITIAL_PUTBACK_BUF_SIZE,
1133                                                   FUNC_NAME);                                                 "putback buffer");
1134            pt->putback_buf_size = SCM_INITIAL_PUTBACK_BUF_SIZE;            pt->putback_buf_size = SCM_INITIAL_PUTBACK_BUF_SIZE;
1135          }          }
1136    

Legend:
Removed from v.1.161  
changed lines
  Added in v.1.162

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26