mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
exclude flexible array size with old compilers
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bbea027027
commit
6b5e0bd98c
6 changed files with 10 additions and 9 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(struct iseq_compile_data_storage));
|
||||
offsetof(struct iseq_compile_data_storage, buff));
|
||||
storage = ISEQ_COMPILE_DATA(iseq)->storage_current = storage->next;
|
||||
storage->next = 0;
|
||||
storage->pos = 0;
|
||||
|
|
2
file.c
2
file.c
|
@ -388,7 +388,7 @@ apply2files(int (*func)(const char *, void *), int argc, VALUE *argv, void *arg)
|
|||
{
|
||||
VALUE v;
|
||||
const size_t size = sizeof(struct apply_filename);
|
||||
const long len = (long)(sizeof(struct apply_arg) + (size * argc));
|
||||
const long len = (long)(offsetof(struct apply_arg, fn) + (size * argc));
|
||||
struct apply_arg *aa = ALLOCV(v, len);
|
||||
|
||||
aa->errnum = 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(struct iseq_compile_data_storage);
|
||||
size += cur->size + offsetof(struct iseq_compile_data_storage, buff);
|
||||
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(struct iseq_compile_data_storage));
|
||||
offsetof(struct iseq_compile_data_storage, buff));
|
||||
|
||||
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, rb_ary_tmp_new(3));
|
||||
ISEQ_COMPILE_DATA(iseq)->storage_head->pos = 0;
|
||||
|
|
7
iseq.h
7
iseq.h
|
@ -256,11 +256,12 @@ static inline int
|
|||
iseq_catch_table_bytes(int n)
|
||||
{
|
||||
enum {
|
||||
catch_table_entries_max = (INT_MAX - sizeof(struct iseq_catch_table)) / sizeof(struct iseq_catch_table_entry)
|
||||
catch_table_entry_size = sizeof(struct iseq_catch_table_entry),
|
||||
catch_table_entries_max = (INT_MAX - offsetof(struct iseq_catch_table, entries)) / catch_table_entry_size
|
||||
};
|
||||
if (n > catch_table_entries_max) rb_fatal("too large iseq_catch_table - %d", n);
|
||||
return (int)(sizeof(struct iseq_catch_table) +
|
||||
n * sizeof(struct iseq_catch_table_entry));
|
||||
return (int)(offsetof(struct iseq_catch_table, entries) +
|
||||
n * catch_table_entry_size);
|
||||
}
|
||||
|
||||
#define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
|
||||
|
|
2
string.c
2
string.c
|
@ -6410,7 +6410,7 @@ rb_str_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc)
|
|||
if (CASEMAP_DEBUG) {
|
||||
fprintf(stderr, "Buffer allocation, capa is %"PRIuSIZE"\n", capa); /* for tuning */
|
||||
}
|
||||
current_buffer->next = xmalloc(sizeof(mapping_buffer) + capa);
|
||||
current_buffer->next = xmalloc(offsetof(mapping_buffer, space) + capa);
|
||||
current_buffer = current_buffer->next;
|
||||
current_buffer->next = NULL;
|
||||
current_buffer->capa = capa;
|
||||
|
|
|
@ -1001,7 +1001,7 @@ generic_ivar_get(VALUE obj, ID id, VALUE undef)
|
|||
static size_t
|
||||
gen_ivtbl_bytes(size_t n)
|
||||
{
|
||||
return sizeof(struct gen_ivtbl) + n * sizeof(VALUE);
|
||||
return offsetof(struct gen_ivtbl, ivptr) + n * sizeof(VALUE);
|
||||
}
|
||||
|
||||
static struct gen_ivtbl *
|
||||
|
|
Loading…
Add table
Reference in a new issue