[前][次][番号順一覧][スレッド一覧]

ruby-changes:49691

From: mame <ko1@a...>
Date: Sat, 13 Jan 2018 21:44:22 +0900 (JST)
Subject: [ruby-changes:49691] mame:r61808 (trunk): iseq.h (struct iseq_catch_table_entry, iseq_compile_data_storage): Use FLEX_ARY_LEN

mame	2018-01-13 21:44:17 +0900 (Sat, 13 Jan 2018)

  New Revision: 61808

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61808

  Log:
    iseq.h (struct iseq_catch_table_entry, iseq_compile_data_storage): Use FLEX_ARY_LEN

  Modified files:
    trunk/compile.c
    trunk/iseq.c
    trunk/iseq.h
Index: iseq.h
===================================================================
--- iseq.h	(revision 61807)
+++ iseq.h	(revision 61808)
@@ -249,7 +249,7 @@ struct iseq_catch_table_entry { https://github.com/ruby/ruby/blob/trunk/iseq.h#L249
 
 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) https://github.com/ruby/ruby/blob/trunk/iseq.h#L260
     };
     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 { https://github.com/ruby/ruby/blob/trunk/iseq.h#L269
     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 {
Index: compile.c
===================================================================
--- compile.c	(revision 61807)
+++ compile.c	(revision 61808)
@@ -868,7 +868,7 @@ compile_data_alloc(rb_iseq_t *iseq, size https://github.com/ruby/ruby/blob/trunk/compile.c#L868
 	    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;
Index: iseq.c
===================================================================
--- iseq.c	(revision 61807)
+++ iseq.c	(revision 61808)
@@ -208,7 +208,7 @@ iseq_memsize(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L208
 
 	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, https://github.com/ruby/ruby/blob/trunk/iseq.c#L333
     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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]