Use MRB_IREP_ARRAY_INIT_SIZE macro. It should be configurable since it is possible to reduce RAM size.

This commit is contained in:
Masaki Muranaka
2013-02-25 13:57:33 +09:00
parent 8a9026426e
commit 6dda588503
2 changed files with 8 additions and 1 deletions
+3
View File
@@ -34,6 +34,9 @@
/* initial size for IV khash; ignored when MRB_USE_IV_SEGLIST is set */
//#define MRB_IVHASH_INIT_SIZE 8
/* initial size for IREP array */
//#define MRB_IREP_ARRAY_INIT_SIZE (256u)
/* default size of khash table bucket */
//#define KHASH_DEFAULT_SIZE 32
+5 -1
View File
@@ -110,6 +110,10 @@ mrb_close(mrb_state *mrb)
mrb_free(mrb, mrb);
}
#ifndef MRB_IREP_ARRAY_INIT_SIZE
# define MRB_IREP_ARRAY_INIT_SIZE (256u)
#endif
mrb_irep*
mrb_add_irep(mrb_state *mrb)
{
@@ -117,7 +121,7 @@ mrb_add_irep(mrb_state *mrb)
mrb_irep *irep;
if (!mrb->irep) {
int max = 256;
size_t max = MRB_IREP_ARRAY_INIT_SIZE;
if (mrb->irep_len > max) max = mrb->irep_len+1;
mrb->irep = (mrb_irep **)mrb_calloc(mrb, max, sizeof(mrb_irep*));