[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: port initialization?
From: |
Marius Vollmer |
Subject: |
Re: port initialization? |
Date: |
08 Aug 2002 19:33:52 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 |
Han-Wen <address@hidden> writes:
> 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.
Yes, but the GC will not notice since "z" still refers to it and
therefore the port cell wont be freed. So we are safe. It's a little
fishy, yes. We could flag the port as closed until its ptab_entry is
set properly. Closed ports do also have a NULL ptab_entry.
> Why not
> [...]
> {
> scm_t_port *newport = scm_add_to_port_table ();
> SCM port = scm_cell (scm_tc16_port, newport);
> newport->port = port;
> ..
> }
This will leak newport when the call to scm_cell throws.
- port initialization?, Han-Wen, 2002/08/04
- Re: port initialization?,
Marius Vollmer <=
- Re: port initialization?, Han-Wen Nienhuys, 2002/08/08
- Re: port initialization?, Marius Vollmer, 2002/08/08
- Re: port initialization?, Han-Wen Nienhuys, 2002/08/08
- Re: port initialization?, Marius Vollmer, 2002/08/08
- Re: port initialization?, Han-Wen Nienhuys, 2002/08/08
- Re: port initialization?, Marius Vollmer, 2002/08/10
- Re: port initialization?, Han-Wen Nienhuys, 2002/08/16
- Re: port initialization?, Marius Vollmer, 2002/08/16
- Re: port initialization?, Lynn Winebarger, 2002/08/08
- Re: port initialization?, Han-Wen Nienhuys, 2002/08/09