Commit 1ff32cfb authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2509 from suzukaze/refactor-gc

Refactor obj_free() in gc.c
parents fce644df 3569723a
...@@ -34,6 +34,9 @@ struct RArray { ...@@ -34,6 +34,9 @@ struct RArray {
#define RARRAY_LEN(a) (RARRAY(a)->len) #define RARRAY_LEN(a) (RARRAY(a)->len)
#define RARRAY_PTR(a) (RARRAY(a)->ptr) #define RARRAY_PTR(a) (RARRAY(a)->ptr)
#define MRB_ARY_SHARED 256 #define MRB_ARY_SHARED 256
#define ARY_SHARED_P(a) ((a)->flags & MRB_ARY_SHARED)
#define ARY_SET_SHARED_FLAG(a) ((a)->flags |= MRB_ARY_SHARED)
#define ARY_UNSET_SHARED_FLAG(a) ((a)->flags &= ~MRB_ARY_SHARED)
void mrb_ary_decref(mrb_state*, mrb_shared_array*); void mrb_ary_decref(mrb_state*, mrb_shared_array*);
MRB_API void mrb_ary_modify(mrb_state*, struct RArray*); MRB_API void mrb_ary_modify(mrb_state*, struct RArray*);
......
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
#define ARY_SHRINK_RATIO 5 /* must be larger than 2 */ #define ARY_SHRINK_RATIO 5 /* must be larger than 2 */
#define ARY_C_MAX_SIZE (SIZE_MAX / sizeof(mrb_value)) #define ARY_C_MAX_SIZE (SIZE_MAX / sizeof(mrb_value))
#define ARY_MAX_SIZE ((ARY_C_MAX_SIZE < (size_t)MRB_INT_MAX) ? (mrb_int)ARY_C_MAX_SIZE : MRB_INT_MAX-1) #define ARY_MAX_SIZE ((ARY_C_MAX_SIZE < (size_t)MRB_INT_MAX) ? (mrb_int)ARY_C_MAX_SIZE : MRB_INT_MAX-1)
#define ARY_SHARED_P(a) ((a)->flags & MRB_ARY_SHARED)
#define ARY_SET_SHARED_FLAG(a) ((a)->flags |= MRB_ARY_SHARED)
#define ARY_UNSET_SHARED_FLAG(a) ((a)->flags &= ~MRB_ARY_SHARED)
static inline mrb_value static inline mrb_value
ary_elt(mrb_value ary, mrb_int offset) ary_elt(mrb_value ary, mrb_int offset)
......
...@@ -648,7 +648,7 @@ obj_free(mrb_state *mrb, struct RBasic *obj) ...@@ -648,7 +648,7 @@ obj_free(mrb_state *mrb, struct RBasic *obj)
break; break;
case MRB_TT_ARRAY: case MRB_TT_ARRAY:
if (obj->flags & MRB_ARY_SHARED) if (ARY_SHARED_P(obj))
mrb_ary_decref(mrb, ((struct RArray*)obj)->aux.shared); mrb_ary_decref(mrb, ((struct RArray*)obj)->aux.shared);
else else
mrb_free(mrb, ((struct RArray*)obj)->ptr); mrb_free(mrb, ((struct RArray*)obj)->ptr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment