subversion-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James McCoy <james...@debian.org>
Subject Re: [PATCH] Fix modification of nil value in Ruby test suite
Date Tue, 17 Nov 2015 13:51:31 GMT
On Nov 17, 2015 8:40 AM, "Philip Martin" <philip.martin@wandisco.com> wrote:
>
> James McCoy <jamessan@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.

Cheers,
James

Mime
View raw message