summaryrefslogtreecommitdiffhomepage
path: root/src/variable.c
diff options
context:
space:
mode:
authorRory OConnell <[email protected]>2020-07-13 15:59:24 -0700
committerRory OConnell <[email protected]>2020-07-13 15:59:24 -0700
commit6f945a09b4a09828667da6d4bad85b8ef50baf9c (patch)
tree3bb7d59185cb7e05fb0fa4ffcbad9f4adbe09509 /src/variable.c
parente7bd7d0eaf677f62d86f27c2e9a917faa5a7d419 (diff)
downloadmruby-6f945a09b4a09828667da6d4bad85b8ef50baf9c.tar.gz
mruby-6f945a09b4a09828667da6d4bad85b8ef50baf9c.zip
Use object iv table size in calculation
Diffstat (limited to 'src/variable.c')
-rw-r--r--src/variable.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/variable.c b/src/variable.c
index 030aa7b00..0755f7d92 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -4,6 +4,7 @@
** See Copyright Notice in mruby.h
*/
+#include <math.h>
#include <mruby.h>
#include <mruby/array.h>
#include <mruby/class.h>
@@ -1128,6 +1129,14 @@ mrb_class_find_path(mrb_state *mrb, struct RClass *c)
return path;
}
+mrb_int
+mrb_obj_iv_tbl_memsize(mrb_state* mrb, mrb_value obj)
+{
+ return sizeof(iv_tbl) +
+ (sizeof(segment) * ceil(iv_size(mrb, mrb_obj_ptr(obj)->iv)/
+ MRB_IV_SEGMENT_SIZE));
+}
+
#define identchar(c) (ISALNUM(c) || (c) == '_' || !ISASCII(c))
mrb_bool