From bff79112a61959902c89757e473ea62346685847 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 21 Sep 2020 08:15:54 +0900 Subject: Dump/load 16 bits for `ilen` and `slen` in `irep`. Those types are `uint16_t` in definition. Also we no longer need padding for `iseq`. --- src/load.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/load.c') diff --git a/src/load.c b/src/load.c index aae1e071b..0e6ae44a6 100644 --- a/src/load.c +++ b/src/load.c @@ -26,13 +26,6 @@ #define SIZE_ERROR_MUL(nmemb, size) ((size_t)(nmemb) > SIZE_MAX / (size)) -static size_t -skip_padding(const uint8_t *buf) -{ - const size_t align = MRB_DUMP_ALIGNMENT; - return -(intptr_t)buf & (align-1); -} - static size_t offset_crc_body(void) { @@ -109,9 +102,8 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag /* ISEQ BLOCK (and CATCH HANDLER TABLE BLOCK) */ irep->clen = bin_to_uint16(src); /* number of catch handler */ src += sizeof(uint16_t); - irep->ilen = (uint16_t)bin_to_uint32(src); - src += sizeof(uint32_t); - src += skip_padding(src); + irep->ilen = bin_to_uint16(src); + src += sizeof(uint16_t); if (irep->ilen > 0) { size_t data_len = sizeof(mrb_code) * irep->ilen + @@ -212,8 +204,8 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag } /* SYMS BLOCK */ - irep->slen = (uint16_t)bin_to_uint32(src); /* syms length */ - src += sizeof(uint32_t); + irep->slen = bin_to_uint16(src); /* syms length */ + src += sizeof(uint16_t); if (irep->slen > 0) { if (SIZE_ERROR_MUL(irep->slen, sizeof(mrb_sym))) { return NULL; -- cgit v1.2.3