guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

port initialization?


From: Han-Wen
Subject: port initialization?
Date: Sun, 4 Aug 2002 16:42:52 +0200

Just looking at some weird valgrind error here,  ...

what about
  
  z = scm_cell (scm_tc16_strport, 0);
  SCM_DEFER_INTS;
  pt = scm_add_to_port_table (z);
  SCM_SET_CELL_TYPE (z, scm_tc16_strport | modes);
  SCM_SETPTAB_ENTRY (z, pt);
  SCM_SETSTREAM (z, SCM_UNPACK (str));

This looks like fishy code to me. When scm_add_to_port_table triggers
GC then it will see the (scm_tc16_strport, 0) cell, which is (or
should be) invalid.

Why not

    scm_t_port * 
    scm_add_to_port_table ()
    {
        scm_t_port *p = gc_malloc( sizeof (scm_t_port));
        p->port = SCM_EOL;
        ...
    }


    {
        scm_t_port *newport =  scm_add_to_port_table ();
        SCM port = scm_cell (scm_tc16_port, newport);
        newport->port = port;
                      ..
    }

Comments? 



--      
Han-Wen Nienhuys   |   address@hidden   |   http://www.cs.uu.nl/~hanwen 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]