--8323328-1912837268-11162866303494
Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1912837268-1116286630=:13494"

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--8323328-1912837268-11162866303494
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

On Tue, 17 May 2005, Nikolai Weibull wrote:

> Ara.T.Howard wrote:
>
>>   static VALUE
>>   convertgslmatrixToRubyMatrix (gsl_matrix * dm)
>>   {
>>     int i, j;
>>     VALUE result;
>>     VALUE rows = rb_ary_new ();
>>     for (i = 0; i < dm->size1; i += 1)
>>       {
>>         VALUE currow = rb_ary_new ();
>>         rb_gc_mark (currow);
>>         rb_ary_push (rows, currow);
>>         for (j = 0; j < dm->size2; j += 1)
>>           {
>>             double val = gsl_matrix_get (dm, i, j);
>>             VALUE rval = rb_float_new (val);
>>             rb_ary_push (currow, rval);
>>           }
>>       }
>>     result = rb_funcall (cMatrix, rb_intern ("rows"), 2, rows, Qnil);
>>     return result;
>>   }
>
> I don understand why you need to rb_gc_mark those values.  Theye
> pointed to by objects on the stack, so a GC sweep won remove them.
> Neither of the volatile specifiers in the original are needed either, as
> you write (or I am definitely missing something).  I don see how they
> would be optimized away anyway.  Well, actually, the 'result' variable
> should be optimized away :-), just return the result of the rb_funcall
> immediately.
>
> Perhaps I don understand what you want to do here,
>        nikolai

just wanting you to confirm exactly what i was thinking.  the code was so
aggressive with rb_gc_mark that i started thinking i might be missing
something!  you'll note my version didn't have them at all...

so we are in total agreement - i'm reading the code for someone else and just
trying to figure out what they thought they were doing.  needless to say this
extension has some memory issues ;-)

thanks for the clarification.

cheers.

-a
-- 
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| renunciation is not getting rid of the things of this world, but accepting
| that they pass away. --aitken roshi
===============================================================================

--8323328-1912837268-11162866303494--
--8323328-1912837268-11162866303494--