class.c (mt_rehash): Fix mrb_calloc argument order

Since mrb_calloc() (along with mrb_calloc) takes two arguments: nmemb
which is number of array elements, and size which is size of the array.
Of course, revsersing does not change the behavior, but we'd like to
respect the original design intention of calloc(3).
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-05-11 20:11:56 +09:00
parent 4704a7700a
commit 6766fcb905
+1 -1
View File
@@ -78,7 +78,7 @@ mt_rehash(mrb_state *mrb, mt_tbl *t)
int new_alloc = old_alloc > 0 ? old_alloc << 1 : 8;
union mt_ptr *old_ptr = t->ptr;
t->ptr = (union mt_ptr*)mrb_calloc(mrb, sizeof(union mt_ptr)+sizeof(mrb_sym), new_alloc);
t->ptr = (union mt_ptr*)mrb_calloc(mrb, new_alloc, sizeof(union mt_ptr)+sizeof(mrb_sym));
t->alloc = new_alloc;
t->size = 0;
if (old_alloc == 0) return;