Fix dump and load with endianess
MODIFY
src/dump.c
src/dump.c
@@ -85,26 +85,8 @@ write_iseq_block(mrb_state *mrb, mrb_irep *irep, uint8_t *buf, uint8_t flags)
cur += uint32_to_bin(irep->ilen, cur); /* number of opcode */
cur += write_padding(cur);
- switch (flags & DUMP_ENDIAN_NAT) {
- case DUMP_ENDIAN_BIG:
- if (bigendian_p()) goto native;
- for (iseq_no = 0; iseq_no < irep->ilen; iseq_no++) {
- cur += uint32_to_bin(irep->iseq[iseq_no], cur); /* opcode */
- }
- break;
- case DUMP_ENDIAN_LIL:
- if (!bigendian_p()) goto native;
- for (iseq_no = 0; iseq_no < irep->ilen; iseq_no++) {
- cur += uint32l_to_bin(irep->iseq[iseq_no], cur); /* opcode */
- }
- break;
-
- native:
- case DUMP_ENDIAN_NAT:
memcpy(cur, irep->iseq, irep->ilen * sizeof(mrb_code));
cur += irep->ilen * sizeof(mrb_code);
- break;
- }
return cur - buf;
}

MODIFY
src/load.c
src/load.c
@@ -83,23 +83,10 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag
irep->flags |= MRB_ISEQ_NO_FREE;
}
else {
- irep->iseq = (mrb_code *)mrb_malloc(mrb, sizeof(mrb_code) * irep->ilen);
- if (flags & FLAG_BYTEORDER_NATIVE) {
- memcpy(irep->iseq, src, sizeof(uint32_t) * irep->ilen);
- src += sizeof(uint32_t) * irep->ilen;
- }
- else if (flags & FLAG_BYTEORDER_BIG) {
- for (i = 0; i < irep->ilen; i++) {
- irep->iseq[i] = (mrb_code)bin_to_uint32(src); /* iseq */
- src += sizeof(uint32_t);
- }
- }
- else {
- for (i = 0; i < irep->ilen; i++) {
- irep->iseq[i] = (mrb_code)bin_to_uint32l(src); /* iseq */
- src += sizeof(uint32_t);
- }
- }
+ size_t data_len = sizeof(mrb_code) * irep->ilen;
+ irep->iseq = (mrb_code *)mrb_malloc(mrb, data_len);
+ memcpy(irep->iseq, src, data_len);
+ src += data_len;
}
}

Fix dump and load with endianess