From 7ad9975fe7e8e22de841b26ed549652326d08c65 Mon Sep 17 00:00:00 2001 From: mame Date: Sat, 13 Jan 2018 12:44:17 +0000 Subject: [PATCH] iseq.h (struct iseq_catch_table_entry, iseq_compile_data_storage): Use FLEX_ARY_LEN git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 2 +- iseq.c | 4 ++-- iseq.h | 10 +++------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/compile.c b/compile.c index 87a1bd8f6a..6fae343d78 100644 --- a/compile.c +++ b/compile.c @@ -868,7 +868,7 @@ compile_data_alloc(rb_iseq_t *iseq, size_t size) alloc_size *= 2; } storage->next = (void *)ALLOC_N(char, alloc_size + - SIZEOF_ISEQ_COMPILE_DATA_STORAGE); + sizeof(struct iseq_compile_data_storage)); storage = ISEQ_COMPILE_DATA(iseq)->storage_current = storage->next; storage->next = 0; storage->pos = 0; diff --git a/iseq.c b/iseq.c index ee49026c9a..57ff506d0a 100644 --- a/iseq.c +++ b/iseq.c @@ -208,7 +208,7 @@ iseq_memsize(const rb_iseq_t *iseq) cur = compile_data->storage_head; while (cur) { - size += cur->size + SIZEOF_ISEQ_COMPILE_DATA_STORAGE; + size += cur->size + sizeof(struct iseq_compile_data_storage); cur = cur->next; } } @@ -333,7 +333,7 @@ prepare_iseq_build(rb_iseq_t *iseq, ISEQ_COMPILE_DATA(iseq)->storage_head = ISEQ_COMPILE_DATA(iseq)->storage_current = (struct iseq_compile_data_storage *) ALLOC_N(char, INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE + - SIZEOF_ISEQ_COMPILE_DATA_STORAGE); + sizeof(struct iseq_compile_data_storage)); RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, rb_ary_tmp_new(3)); ISEQ_COMPILE_DATA(iseq)->storage_head->pos = 0; diff --git a/iseq.h b/iseq.h index 639d12bf24..daeac0c889 100644 --- a/iseq.h +++ b/iseq.h @@ -249,7 +249,7 @@ struct iseq_catch_table_entry { PACKED_STRUCT_UNALIGNED(struct iseq_catch_table { unsigned int size; - struct iseq_catch_table_entry entries[1]; /* flexible array */ + struct iseq_catch_table_entry entries[FLEX_ARY_LEN]; }); static inline int @@ -260,7 +260,7 @@ iseq_catch_table_bytes(int n) }; if (n > catch_table_entries_max) rb_fatal("too large iseq_catch_table - %d", n); return (int)(sizeof(struct iseq_catch_table) + - (n - 1) * sizeof(struct iseq_catch_table_entry)); + n * sizeof(struct iseq_catch_table_entry)); } #define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512) @@ -269,13 +269,9 @@ struct iseq_compile_data_storage { struct iseq_compile_data_storage *next; unsigned int pos; unsigned int size; - char buff[1]; /* flexible array */ + char buff[FLEX_ARY_LEN]; }; -/* account for flexible array */ -#define SIZEOF_ISEQ_COMPILE_DATA_STORAGE \ - (sizeof(struct iseq_compile_data_storage) - 1) - /* defined? */ enum defined_type {