We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c1f7039 commit 7a36808Copy full SHA for 7a36808
1 file changed
internal/imemo.h
@@ -195,21 +195,13 @@ RB_IMEMO_TMPBUF_PTR(VALUE v)
195
static inline VALUE
196
rb_imemo_tmpbuf_new_from_an_RString(VALUE str)
197
{
198
- const void *src;
199
VALUE imemo;
200
- rb_imemo_tmpbuf_t *tmpbuf;
201
- void *dst;
202
size_t len;
203
204
StringValue(str);
205
- /* create tmpbuf to keep the pointer before xmalloc */
206
- imemo = rb_imemo_tmpbuf_new();
207
- tmpbuf = (rb_imemo_tmpbuf_t *)imemo;
208
len = RSTRING_LEN(str);
209
- src = RSTRING_PTR(str);
210
- dst = ruby_xmalloc(len);
211
- memcpy(dst, src, len);
212
- tmpbuf->ptr = dst;
+ rb_alloc_tmp_buffer(&imemo, len);
+ memcpy(RB_IMEMO_TMPBUF_PTR(imemo), RSTRING_PTR(str), len);
213
return imemo;
214
}
215
0 commit comments