[macruby-changes] [819] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Sat Feb 28 12:38:50 PST 2009


Revision: 819
          http://trac.macosforge.org/projects/ruby/changeset/819
Author:   lsansonetti at apple.com
Date:     2009-02-28 12:38:50 -0800 (Sat, 28 Feb 2009)
Log Message:
-----------
fixed GC leaks

Modified Paths:
--------------
    MacRuby/trunk/include/ruby/io.h
    MacRuby/trunk/io.c
    MacRuby/trunk/thread.c

Modified: MacRuby/trunk/include/ruby/io.h
===================================================================
--- MacRuby/trunk/include/ruby/io.h	2009-02-28 20:33:06 UTC (rev 818)
+++ MacRuby/trunk/include/ruby/io.h	2009-02-28 20:38:50 UTC (rev 819)
@@ -72,7 +72,8 @@
 	RFILE(obj)->fptr = 0;\
     }\
     fp = 0;\
-    fp = RFILE(obj)->fptr = ALLOC(rb_io_t);\
+    fp = ALLOC(rb_io_t);\
+    GC_WB(&RFILE(obj)->fptr, fp);\
     fp->fd = -1;\
     fp->stdio_file = NULL;\
     fp->mode = 0;\

Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c	2009-02-28 20:33:06 UTC (rev 818)
+++ MacRuby/trunk/io.c	2009-02-28 20:38:50 UTC (rev 819)
@@ -656,7 +656,7 @@
 int
 rb_io_wait_writable(int f)
 {
-    rb_fdset_t wfds;
+    rb_fdset_t *wfds = xmalloc(sizeof(rb_fdset_t));
 
     switch (errno) {
       case EINTR:
@@ -670,13 +670,13 @@
 #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
       case EWOULDBLOCK:
 #endif
-	rb_fd_init(&wfds);
-	rb_fd_set(f, &wfds);
+	rb_fd_init(wfds);
+	rb_fd_set(f, wfds);
 #ifdef HAVE_RB_FD_INIT
-	rb_ensure(wait_writable, (VALUE)&wfds,
-		  (VALUE (*)(VALUE))rb_fd_term, (VALUE)&wfds);
+	rb_ensure(wait_writable, (VALUE)wfds,
+		  (VALUE (*)(VALUE))rb_fd_term, (VALUE)wfds);
 #else
-	rb_thread_select(f + 1, NULL, &wfds, NULL, NULL);
+	rb_thread_select(f + 1, NULL, wfds, NULL, NULL);
 #endif
 	return Qtrue;
 

Modified: MacRuby/trunk/thread.c
===================================================================
--- MacRuby/trunk/thread.c	2009-02-28 20:33:06 UTC (rev 818)
+++ MacRuby/trunk/thread.c	2009-02-28 20:38:50 UTC (rev 819)
@@ -1786,7 +1786,7 @@
     if (o < sizeof(fd_set)) o = sizeof(fd_set);
 
     if (m > o) {
-	fds->fdset = realloc(fds->fdset, m);
+	GC_WB(&fds->fdset, realloc(fds->fdset, m));
 	memset((char *)fds->fdset + o, 0, m - o);
     }
     if (n >= fds->maxfd) fds->maxfd = n + 1;
@@ -1820,7 +1820,7 @@
 
     if (size < sizeof(fd_set)) size = sizeof(fd_set);
     dst->maxfd = max;
-    dst->fdset = realloc(dst->fdset, size);
+    GC_WB(&dst->fdset, realloc(dst->fdset, size));
     memcpy(dst->fdset, src, size);
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090228/5192a1ca/attachment.html>


More information about the macruby-changes mailing list