'unexpected return' caused by extension

I’m writing my first (useful) Ruby extension, and I’m having issues. I’m
sure it’s just a combination of my lack of C knowledge and lack of Ruby
knowledge, but I’d be extremely grateful for any pointers you might have.

Basically, I’m trying to write a better, faster profiler. I’ve attached all
of the interesting bits. When I run this on the tests from the most recent
Ruby (actually, just trying to get help!), I get the following error:

ntalbott@solomon:~/cvs/ruby/test$ ruby -v -I ~/nprof -rnprofit runner.rb
–help
/usr/local/lib/ruby/1.8/test/unit/autorunner.rb:10: unexpected return
ruby 1.8.0 (2003-10-10) [i686-linux]

Running it without the extension works as expected. I’m sure I’m doing
something stupid… I promise to slap myself on the forehead when someone
shows me what it is.

Also, if you have any suggests regarding my C and/or Ruby/C style, please
let me know. I’m looking to improve as much as possible.

Thanks,

Nathaniel

<:((><

nprofit.rb (127 Bytes)

nprof.rb (623 Bytes)

nprofext.c (5.13 KB)

extconf.rb (44 Bytes)

Hi,

···

In message “‘unexpected return’ caused by extension” on 03/10/11, “Nathaniel Talbott” nathaniel@NOSPAMtalbott.ws writes:

I’m writing my first (useful) Ruby extension, and I’m having issues. I’m
sure it’s just a combination of my lack of C knowledge and lack of Ruby
knowledge, but I’d be extremely grateful for any pointers you might have.

Basically, I’m trying to write a better, faster profiler. I’ve attached all
of the interesting bits. When I run this on the tests from the most recent
Ruby (actually, just trying to get help!), I get the following error:

ntalbott@solomon:~/cvs/ruby/test$ ruby -v -I ~/nprof -rnprofit runner.rb
–help
/usr/local/lib/ruby/1.8/test/unit/autorunner.rb:10: unexpected return
ruby 1.8.0 (2003-10-10) [i686-linux]

Running it without the extension works as expected. I’m sure I’m doing
something stupid… I promise to slap myself on the forehead when someone
shows me what it is.

It’s a bug. I fixed it in the latest CVS.

						matz.