* freeing fports
@ 2003-08-27 4:56 Aaron VanDevender
2003-09-23 23:49 ` Kevin Ryde
0 siblings, 1 reply; 3+ messages in thread
From: Aaron VanDevender @ 2003-08-27 4:56 UTC (permalink / raw)
I noticed that the fport free function doesn't return how much
it frees. This patch should take care of that.
--- libguile.old/fports.c 2003-08-26 23:35:34.000000000 -0500
+++ libguile/fports.c 2003-08-26 23:47:23.000000000 -0500
@@ -827,8 +827,11 @@
static size_t
fport_free (SCM port)
{
+ size_t size;
+ scm_t_port *pt = SCM_PTAB_ENTRY (port);
+ size = pt->read_buf_size + pt->write_buf_size + sizeof(scm_t_fport);
fport_close (port);
- return 0;
+ return size;
}
static scm_t_bits
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: freeing fports
2003-08-27 4:56 freeing fports Aaron VanDevender
@ 2003-09-23 23:49 ` Kevin Ryde
2003-09-24 18:06 ` Aaron VanDevender
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Ryde @ 2003-09-23 23:49 UTC (permalink / raw)
Cc: guile-user
[-- Attachment #1: Type: text/plain, Size: 739 bytes --]
Aaron VanDevender <sig@netdot.net> writes:
>
> I noticed that the fport free function doesn't return how much
> it frees.
Thanks.
> This patch should take care of that.
No, not quite, I think you need to allow for buffers possibly being
"shortbuf" (size 1), which is not freed.
Probably best to make the adjustment in fport_close, since a port can
be closed before it's freed. setvbuf looks like it suffers the same
sort of leak.
* fports.c (scm_setvbuf, fport_close): Call scm_done_free for space
freed.
Unfortunately this still doesn't make open+close leave scm_mallocated
unchanged, so maybe there's a leak somewhere else too. Maybe it's not
worth worrying about in the 1.6 branch. Seems ok in the latest cvs.
[-- Attachment #2: fports.c.done_free.diff --]
[-- Type: text/plain, Size: 1111 bytes --]
--- fports.c.~1.100.2.4.~ 1970-01-01 10:00:01.000000000 +1000
+++ fports.c 2003-09-22 14:51:58.000000000 +1000
@@ -191,9 +191,15 @@
/* silently discards buffered chars. */
if (pt->read_buf != &pt->shortbuf)
- scm_must_free (pt->read_buf);
+ {
+ scm_must_free (pt->read_buf);
+ scm_done_free (pt->read_buf_size);
+ }
if (pt->write_buf != &pt->shortbuf)
- scm_must_free (pt->write_buf);
+ {
+ scm_must_free (pt->write_buf);
+ scm_done_free (pt->write_buf_size);
+ }
scm_fport_buffer_add (port, csize, csize);
return SCM_UNSPECIFIED;
@@ -817,10 +823,17 @@
if (pt->read_buf == pt->putback_buf)
pt->read_buf = pt->saved_read_buf;
if (pt->read_buf != &pt->shortbuf)
- scm_must_free (pt->read_buf);
+ {
+ scm_must_free (pt->read_buf);
+ scm_done_free (pt->read_buf_size);
+ }
if (pt->write_buf != &pt->shortbuf)
- scm_must_free (pt->write_buf);
+ {
+ scm_must_free (pt->write_buf);
+ scm_done_free (pt->write_buf_size);
+ }
scm_must_free ((char *) fp);
+ scm_done_free (sizeof (*fp));
return rv;
}
[-- Attachment #3: Type: text/plain, Size: 139 bytes --]
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: freeing fports
2003-09-23 23:49 ` Kevin Ryde
@ 2003-09-24 18:06 ` Aaron VanDevender
0 siblings, 0 replies; 3+ messages in thread
From: Aaron VanDevender @ 2003-09-24 18:06 UTC (permalink / raw)
Cc: guile-user
On Wed, Sep 24, 2003 at 09:49:22AM +1000, Kevin Ryde wrote:
> Unfortunately this still doesn't make open+close leave scm_mallocated
> unchanged, so maybe there's a leak somewhere else too. Maybe it's not
> worth worrying about in the 1.6 branch. Seems ok in the latest cvs.
I don't think its worth worrying about, as this is all based on
scm_must_malloc/free which has been depricated in HEAD in favour
of scm_gc_malloc. I just wrote the patch because I was working
on a new port implementation for 1.6 and noticed the fport was
always returning 0, but I've since moved on to the 1.7 way of
doing things.
cya
.sig
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-09-24 18:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-27 4:56 freeing fports Aaron VanDevender
2003-09-23 23:49 ` Kevin Ryde
2003-09-24 18:06 ` Aaron VanDevender
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).