diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-11-07 04:20:46 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-11-07 04:20:46 +0900 |
| commit | 677a2ac22633473fb286d7297a8585c01fe7394b (patch) | |
| tree | b0052f5b50bfb490c9780c6dd0645a2742aaf655 /src/load.c | |
| parent | e92d4e2680716d3e16a264e46394cb6e458699f9 (diff) | |
| download | mruby-677a2ac22633473fb286d7297a8585c01fe7394b.tar.gz mruby-677a2ac22633473fb286d7297a8585c01fe7394b.zip | |
irep->pool not to be GCed
Diffstat (limited to 'src/load.c')
| -rw-r--r-- | src/load.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/load.c b/src/load.c index 9a229b8ee..cb698dfe6 100644 --- a/src/load.c +++ b/src/load.c @@ -87,7 +87,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, uint32_t *len) if (SIZE_ERROR_MUL(sizeof(mrb_value), plen)) { return NULL; } - irep->pool = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value) * plen); + irep->pool = (struct irep_pool*)mrb_malloc(mrb, sizeof(struct irep_pool) * plen); if (irep->pool == NULL) { return NULL; } @@ -99,21 +99,24 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, uint32_t *len) src += sizeof(uint16_t); s = mrb_str_new(mrb, (char *)src, pool_data_len); src += pool_data_len; + irep->pool[i].type = tt; switch (tt) { //pool data case MRB_TT_FIXNUM: - irep->pool[i] = mrb_str_to_inum(mrb, s, 10, FALSE); + irep->pool[i].value.i = mrb_fixnum(mrb_str_to_inum(mrb, s, 10, FALSE)); break; case MRB_TT_FLOAT: - irep->pool[i] = mrb_float_value(mrb, mrb_str_to_dbl(mrb, s, FALSE)); + irep->pool[i].value.f = mrb_str_to_dbl(mrb, s, FALSE); break; case MRB_TT_STRING: - irep->pool[i] = s; + irep->pool[i].value.s = (struct irep_pool_string*)mrb_malloc(mrb, sizeof(struct irep_pool_string) + pool_data_len); + irep->pool[i].value.s->len = pool_data_len; + memcpy(irep->pool[i].value.s->buf, src-pool_data_len, pool_data_len); break; default: - irep->pool[i] = mrb_nil_value(); + /* should not happen */ break; } irep->plen++; |
