summaryrefslogtreecommitdiffhomepage
path: root/src/array.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-08-12 21:47:23 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-10-12 16:21:36 +0900
commit8813ebec07b4da46bf21a06cd16987208a442991 (patch)
tree2cc9213de89a3ac29f8f13e5c62d3e55e49b6916 /src/array.c
parenta93ef815be794a5afdaffd33b896cd64dc5f0a75 (diff)
downloadmruby-8813ebec07b4da46bf21a06cd16987208a442991.tar.gz
mruby-8813ebec07b4da46bf21a06cd16987208a442991.zip
Skip array embedding if `MRB_NO_BOXING` and `MRB_32BIT`; fix #4382
On some platforms, `sizeof(mrb_value) > sizeof(void*)*3`, which makes `MRB_ARY_EMBED_LEN_MAX` zero. And zero sized array cause compile errors.
Diffstat (limited to 'src/array.c')
-rw-r--r--src/array.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/array.c b/src/array.c
index f86743138..285600969 100644
--- a/src/array.c
+++ b/src/array.c
@@ -1123,8 +1123,14 @@ mrb_ary_clear(mrb_state *mrb, mrb_value self)
else if (!ARY_EMBED_P(a)){
mrb_free(mrb, a->as.heap.ptr);
}
- ARY_SET_EMBED_LEN(a, 0);
-
+ if (MRB_ARY_EMBED_LEN_MAX > 0) {
+ ARY_SET_EMBED_LEN(a, 0);
+ }
+ else {
+ a->as.heap.ptr = NULL;
+ a->as.heap.aux.capa = 0;
+ ARY_SET_LEN(a, 0);
+ }
return self;
}