From: "Ara.T.Howard" Date: 2005-05-17T07:40:31+09:00 Subject: rb_gc_mark question i reading some code attm that goes: static VALUE convertgslmatrixToRubyMatrix(gsl_matrix *dm) { int i, j; volatile VALUE result; assert(dm); // printf("Trying to convert dm %p\n", dm); // printf("With size %d, %d\n", dm->size1, dm->size2); volatile VALUE rows = rb_ary_new(); rb_gc_mark(rows); for (i = 0; i < dm->size1; i += 1) { volatile 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_gc_mark(rval); rb_ary_push(currow, rval); } } result = rb_funcall(cMatrix, rb_intern("rows"), 2, rows, Qnil); rb_gc_mark(result); return result; } now, everything i know says this should be something along the lines of: 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; } (please correct me if i'm wrong) or nasty things will happen in memory right? what would it do to call rb_gc_mark on ruby objects like this? 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 ===============================================================================