зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
879df66d96
Коммит
7ad9975fe7
|
@ -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;
|
||||
|
|
4
iseq.c
4
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;
|
||||
|
|
10
iseq.h
10
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 {
|
||||
|
|
Загрузка…
Ссылка в новой задаче