summaryrefslogtreecommitdiff
path: root/ext/-test-/bug-3652/bug.c
blob: 290ac2ddee2507c74b635b877fab4991df19b4ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <ruby.h>

static VALUE
bug_str_resize(VALUE self, VALUE init, VALUE repl)
{
    long initlen = NUM2LONG(init);
    VALUE s = rb_str_buf_new(initlen);
    return rb_str_resize(s, strlcpy(RSTRING_PTR(s), StringValueCStr(repl), (size_t)initlen));
}

void
Init_bug(void)
{
    VALUE mBug = rb_define_module("Bug");
    rb_define_module_function(mBug, "str_resize", bug_str_resize, 2);
}