Skip to content

Commit

Permalink
Change call_into_ruby_mem_leak to use eval
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzhu2118 committed May 1, 2024
1 parent 274b95f commit 8f88ed6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions test/ruby_memcheck/ext/ruby_memcheck_c_test_one.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ static VALUE c_test_one_uninitialized_value(VALUE _)

static VALUE c_test_one_call_into_ruby_mem_leak(VALUE obj)
{
char str[20];
for (int i = 0; i < 10000; i++) {
sprintf(str, "foobar%d", i);
rb_intern(str);
}
VALUE string = rb_eval_string("String.new(capacity: 10_000)");
RSTRING(string)->as.heap.ptr = NULL;

return Qnil;
}

Expand Down
8 changes: 3 additions & 5 deletions test/ruby_memcheck/ext/ruby_memcheck_c_test_two.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ static VALUE c_test_two_uninitialized_value(VALUE _)

static VALUE c_test_two_call_into_ruby_mem_leak(VALUE obj)
{
char str[20];
for (int i = 0; i < 10000; i++) {
sprintf(str, "foobar%d", i);
rb_intern(str);
}
VALUE string = rb_eval_string("String.new(capacity: 10_000)");
RSTRING(string)->as.heap.ptr = NULL;

return Qnil;
}

Expand Down

0 comments on commit 8f88ed6

Please sign in to comment.