diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-13 12:44:17 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-13 12:44:17 +0000 |
commit | 7ad9975fe7e8e22de841b26ed549652326d08c65 (patch) | |
tree | 673600ac2e387fb3164c8480164d5a4a70f776a0 | |
parent | 879df66d96ea7d822de2ea06602a1bba0ee5cb52 (diff) |
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
-rw-r--r-- | compile.c | 2 | ||||
-rw-r--r-- | iseq.c | 4 | ||||
-rw-r--r-- | iseq.h | 10 |
3 files changed, 6 insertions, 10 deletions
@@ -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; @@ -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; @@ -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 { |