Merge pull request #5045 from dearblue/memsize_of

Improve `mruby-os-memsize`
This commit is contained in:
Yukihiro "Matz" Matsumoto
2020-07-24 12:02:05 +09:00
committed by GitHub
6 changed files with 23 additions and 235 deletions
+3 -4
View File
@@ -4,7 +4,6 @@
** See Copyright Notice in mruby.h
*/
#include <math.h>
#include <mruby.h>
#include <mruby/array.h>
#include <mruby/class.h>
@@ -1132,9 +1131,9 @@ mrb_class_find_path(mrb_state *mrb, struct RClass *c)
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));
size_t ivsize = iv_size(mrb, mrb_obj_ptr(obj)->iv);
size_t ivsegs = (ivsize + MRB_IV_SEGMENT_SIZE - 1) / MRB_IV_SEGMENT_SIZE;
return sizeof(iv_tbl) + (sizeof(segment) * ivsegs);
}
#define identchar(c) (ISALNUM(c) || (c) == '_' || !ISASCII(c))