On Tue, Nov 17, 2015 at 08:51:31AM -0500, James McCoy wrote:
> On Nov 17, 2015 8:40 AM, "Philip Martin" <philip.martin_at_wandisco.com> wrote:
> >
> > James McCoy <jamessan_at_debian.org> writes:
> >
> > > --- a/subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c
> > > +++ b/subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c
> > > @@ -3230,14 +3230,16 @@ svn_swig_rb_make_stream(VALUE io)
> > > stream_p = &stream;
> > > r2c_swig_type2(io, "svn_stream_t *", (void **)stream_p);
> > > } else {
> > > + if (NIL_P(io)) {
> > > + io = rb_class_new_instance(0, NULL, rb_cObject);
> > > + }
> > > VALUE rb_pool = rb_pool_new(Qnil);
> > > - apr_pool_wrapper_t *pool_wrapper;
> > > - apr_pool_wrapper_t **pool_wrapper_p;
> > > + apr_pool_t *pool;
> > > +
> > > + svn_swig_rb_get_pool(0, NULL, io, &rb_pool, &pool);
> > >
> > > rb_set_pool(io, rb_pool);
> > > - pool_wrapper_p = &pool_wrapper;
> > > - r2c_swig_type2(rb_pool, "apr_pool_wrapper_t *", (void **)
> pool_wrapper_p);
> > > - stream = svn_stream_create((void *)io, pool_wrapper->pool);
> > > + stream = svn_stream_create((void *)io, pool);
> > > svn_stream_set_read2(stream, NULL /* only full read support */,
> > > read_handler_rbio);
> > > svn_stream_set_write(stream, write_handler_rbio);
> >
> > That works when I try it but I'm not familar with Ruby. I know Ruby has
> > GC but what controls the lifetime of the io object and how long does it
> > need to persist?
>
> Good questions. I don't know the answers, unfortunately. I just tried to follow
> the style of other, similar code as I don't really grok Ruby's C API and didn't
> find great documentation about it.
Instead, I committed a fix to the test itself (passing in a new Object
instead of nil) in r1766240.
Cheers,
--
James
GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7 2D23 DFE6 91AE 331B A3DB
Received on 2016-10-23 04:37:00 CEST