Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to the TypedData API #222

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion ext/stackprof/stackprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,12 @@ stackprof_gc_mark(void *data)
}
}

static size_t
stackprof_memsize(const void *data)
{
return sizeof(_stackprof);
}

static void
stackprof_atfork_prepare(void)
{
Expand Down Expand Up @@ -889,6 +895,15 @@ stackprof_at_exit(ruby_vm_t* vm)
ruby_vm_running = 0;
}

static const rb_data_type_t stackprof_type = {
"StackProf",
{
stackprof_gc_mark,
NULL,
stackprof_memsize,
}
};

void
Init_stackprof(void)
{
Expand Down Expand Up @@ -936,8 +951,8 @@ Init_stackprof(void)
/* Need to run this to warm the symbol table before we call this during GC */
rb_gc_latest_gc_info(sym_state);

gc_hook = Data_Wrap_Struct(rb_cObject, stackprof_gc_mark, NULL, &_stackprof);
rb_global_variable(&gc_hook);
gc_hook = TypedData_Wrap_Struct(rb_cObject, &stackprof_type, &_stackprof);

_stackprof.raw_samples = NULL;
_stackprof.raw_samples_len = 0;
Expand Down
Loading