summaryrefslogtreecommitdiff
path: root/imemo.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2025-09-13 14:10:57 -0400
committerPeter Zhu <peter@peterzhu.ca>2025-09-15 09:25:20 -0400
commitb0ce1fd549a3227ef4d9f65e4cdf0df93e4adeb0 (patch)
tree23ff1570f9d6fb06781982fb0e324e47e8bbbdbf /imemo.c
parent70210acab046239beedf880edf0330e3cb389ce8 (diff)
Combine rb_imemo_tmpbuf_auto_free_pointer and rb_imemo_tmpbuf_new
Diffstat (limited to 'imemo.c')
-rw-r--r--imemo.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/imemo.c b/imemo.c
index 02cba387bd..1bef7a71a6 100644
--- a/imemo.c
+++ b/imemo.c
@@ -48,23 +48,14 @@ rb_imemo_new(enum imemo_type type, VALUE v0, size_t size)
return (VALUE)obj;
}
-static rb_imemo_tmpbuf_t *
-rb_imemo_tmpbuf_new(void)
-{
- return IMEMO_NEW(rb_imemo_tmpbuf_t, imemo_tmpbuf, 0);
-}
-
void *
rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t size, size_t cnt)
{
- void *ptr;
- rb_imemo_tmpbuf_t *tmpbuf;
-
/* Keep the order; allocate an empty imemo first then xmalloc, to
* get rid of potential memory leak */
- tmpbuf = rb_imemo_tmpbuf_new();
+ rb_imemo_tmpbuf_t *tmpbuf = (rb_imemo_tmpbuf_t *)rb_imemo_tmpbuf_new();
*store = (VALUE)tmpbuf;
- ptr = ruby_xmalloc(size);
+ void *ptr = ruby_xmalloc(size);
tmpbuf->ptr = ptr;
tmpbuf->cnt = cnt;
@@ -97,7 +88,7 @@ rb_free_tmp_buffer(volatile VALUE *store)
rb_imemo_tmpbuf_t *
rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt)
{
- rb_imemo_tmpbuf_t *tmpbuf = rb_imemo_tmpbuf_new();
+ rb_imemo_tmpbuf_t *tmpbuf = (rb_imemo_tmpbuf_t *)rb_imemo_tmpbuf_new();
tmpbuf->ptr = buf;
tmpbuf->next = old_heap;
tmpbuf->cnt = cnt;