From 33f54da15ba137fc1569016f5caa492c1a57eb4d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 23 Jul 2019 16:18:40 +0900 Subject: [PATCH] Support memsize of AST --- ast.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ast.c b/ast.c index a1af214b33..4c6477d3c9 100644 --- a/ast.c +++ b/ast.c @@ -22,9 +22,16 @@ node_gc_mark(void *ptr) rb_gc_mark((VALUE)data->ast); } +static size_t +node_memsize(const void *ptr) +{ + struct ASTNodeData *data = (struct ASTNodeData *)ptr; + return rb_ast_memsize(data->ast); +} + static const rb_data_type_t rb_node_type = { "AST/node", - {node_gc_mark, RUBY_TYPED_DEFAULT_FREE, 0,}, + {node_gc_mark, RUBY_TYPED_DEFAULT_FREE, node_memsize,}, 0, 0, RUBY_TYPED_FREE_IMMEDIATELY, };