Skip to content

Commit

Permalink
fix some segfaults and such
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Sep 17, 2012
1 parent 41a3539 commit 7817974
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ext/rblineprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ profiler_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
} else { // regex mode
st_lookup(rblineprof.files, (st_data_t)file, (st_data_t *)&sourcefile);

if ((long)sourcefile == Qnil) // known negative match, skip
if ((VALUE)sourcefile == Qnil) // known negative match, skip
return;

if (!sourcefile) { // unknown file, check against regex
Expand Down Expand Up @@ -107,15 +107,15 @@ profiler_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
static int
gc_mark_files(st_data_t key, st_data_t record, st_data_t arg)
{
rb_source_filename((char *)record);
rb_source_filename((char *)key);
return ST_CONTINUE;
}

static int
cleanup_files(st_data_t key, st_data_t record, st_data_t arg)
{
sourcefile_t *sourcefile = (sourcefile_t*)record;
if (!sourcefile || (long)sourcefile == Qnil) return;
if (!sourcefile || (VALUE)sourcefile == Qnil) return ST_DELETE;

if (sourcefile->lines)
free(sourcefile->lines);
Expand All @@ -128,10 +128,11 @@ static int
summarize_files(st_data_t key, st_data_t record, st_data_t arg)
{
VALUE ret = (VALUE)arg;
VALUE ary = rb_ary_new();
sourcefile_t *sourcefile = (sourcefile_t*)record;
if (!sourcefile || (VALUE)sourcefile == Qnil) return ST_CONTINUE;
long i;

VALUE ary = rb_ary_new();
for (i=0; i<sourcefile->nlines; i++)
rb_ary_store(ary, i, ULL2NUM(sourcefile->lines[i]));
rb_hash_aset(ret, rb_str_new2(sourcefile->filename), ary);
Expand Down

0 comments on commit 7817974

Please sign in to comment.