diff options
| author | mirichi <[email protected]> | 2013-07-06 08:31:01 +0900 |
|---|---|---|
| committer | mirichi <[email protected]> | 2013-07-06 08:31:01 +0900 |
| commit | c3e81aca651100e40a03494c9fcc7b8e84302b0a (patch) | |
| tree | e7256423448ca4f42f9e11f98bc8881829fd32bb /src/load.c | |
| parent | a01845b502a902ee1de2f34645177e64fafbb551 (diff) | |
| parent | d4b8fdd7a56ac17064bfcce75df25f100b4a407c (diff) | |
| download | mruby-c3e81aca651100e40a03494c9fcc7b8e84302b0a.tar.gz mruby-c3e81aca651100e40a03494c9fcc7b8e84302b0a.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/load.c')
| -rw-r--r-- | src/load.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/load.c b/src/load.c index e832de628..092ddbde8 100644 --- a/src/load.c +++ b/src/load.c @@ -187,7 +187,6 @@ read_rite_section_irep(mrb_state *mrb, const uint8_t *bin) { int result; size_t sirep; - size_t i; uint32_t len; uint16_t nirep; uint16_t n; @@ -200,14 +199,14 @@ read_rite_section_irep(mrb_state *mrb, const uint8_t *bin) nirep = bin_to_uint16(header->nirep); //Read Binary Data Section - for (n = 0, i = sirep; n < nirep; n++, i++) { + for (n = 0; n < nirep; n++) { result = read_rite_irep_record(mrb, bin, &len); if (result != MRB_DUMP_OK) goto error_exit; bin += len; } - result = sirep + bin_to_uint16(header->sirep); + result = nirep; error_exit: if (result < MRB_DUMP_OK) { irep_free(sirep, mrb); @@ -368,7 +367,7 @@ mrb_read_irep(mrb_state *mrb, const uint8_t *bin) bin += bin_to_uint32(section_header->section_size); } while (memcmp(section_header->section_identify, RITE_BINARY_EOF, sizeof(section_header->section_identify)) != 0); - return total_nirep; + return sirep; } static void @@ -464,7 +463,6 @@ read_rite_section_irep_file(mrb_state *mrb, FILE *fp) { int32_t result; size_t sirep; - size_t i; uint16_t nirep; uint16_t n; uint32_t len, buf_size; @@ -488,7 +486,7 @@ read_rite_section_irep_file(mrb_state *mrb, FILE *fp) } //Read Binary Data Section - for (n = 0, i = sirep; n < nirep; n++, i++) { + for (n = 0; n < nirep; n++) { void *ptr; if (fread(buf, record_header_size, 1, fp) == 0) { @@ -516,7 +514,7 @@ read_rite_section_irep_file(mrb_state *mrb, FILE *fp) goto error_exit; } - result = sirep + bin_to_uint16(header.sirep); + result = nirep; error_exit: if (buf) { mrb_free(mrb, buf); @@ -567,7 +565,7 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp) fpos = ftell(fp); /* You don't need use SIZE_ERROR as block_size is enough small. */ for (i = 0; i < block_fallback_count; i++,block_size >>= 1){ - buf = mrb_malloc(mrb, block_size); + buf = mrb_malloc_simple(mrb, block_size); if (buf) break; } if (!buf) { @@ -614,7 +612,7 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp) fseek(fp, fpos + section_size, SEEK_SET); } while (memcmp(section_header.section_identify, RITE_BINARY_EOF, sizeof(section_header.section_identify)) != 0); - return total_nirep; + return sirep; } mrb_value |
