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

ruby-changes:51278

From: normal <ko1@a...>
Date: Tue, 22 May 2018 09:44:34 +0900 (JST)
Subject: [ruby-changes:51278] normal:r63484 (trunk): parse.y: use ruby_sized_xfree and SIZED_REALLOC_N

normal	2018-05-22 09:44:22 +0900 (Tue, 22 May 2018)

  New Revision: 63484

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

  Log:
    parse.y: use ruby_sized_xfree and SIZED_REALLOC_N
    
    Another part of the plan to reduce dependencies on malloc_usable_size
    which costs us speed: https://bugs.ruby-lang.org/issues/10238

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 63483)
+++ parse.y	(revision 63484)
@@ -4577,7 +4577,7 @@ token_info_pop(struct parser_params *p, https://github.com/ruby/ruby/blob/trunk/parse.y#L4577
 
     /* indentation check of matched keywords (begin..end, if..end, etc.) */
     token_info_warn(p, token, ptinfo_beg, 1, loc);
-    xfree(ptinfo_beg);
+    ruby_sized_xfree(ptinfo_beg, sizeof(*ptinfo_beg));
 }
 
 static void
@@ -4755,9 +4755,9 @@ vtable_free_gen(struct parser_params *p, https://github.com/ruby/ruby/blob/trunk/parse.y#L4755
 #endif
     if (!DVARS_TERMINAL_P(tbl)) {
 	if (tbl->tbl) {
-	    xfree(tbl->tbl);
+	    ruby_sized_xfree(tbl->tbl, tbl->capa * sizeof(ID));
 	}
-	xfree(tbl);
+	ruby_sized_xfree(tbl, sizeof(tbl));
     }
 }
 #define vtable_free(tbl) vtable_free_gen(p, __LINE__, #tbl, tbl)
@@ -4778,7 +4778,7 @@ vtable_add_gen(struct parser_params *p, https://github.com/ruby/ruby/blob/trunk/parse.y#L4778
     }
     if (tbl->pos == tbl->capa) {
 	tbl->capa = tbl->capa * 2;
-	REALLOC_N(tbl->tbl, ID, tbl->capa);
+	SIZED_REALLOC_N(tbl->tbl, ID, tbl->capa, tbl->pos);
     }
     tbl->tbl[tbl->pos++] = id;
 }
@@ -10340,7 +10340,7 @@ local_pop(struct parser_params *p) https://github.com/ruby/ruby/blob/trunk/parse.y#L10340
     vtable_free(p->lvtbl->vars);
     CMDARG_POP();
     COND_POP();
-    xfree(p->lvtbl);
+    ruby_sized_xfree(p->lvtbl, sizeof(*p->lvtbl));
     p->lvtbl = local;
 }
 
@@ -10469,7 +10469,7 @@ dyna_pop(struct parser_params *p, const https://github.com/ruby/ruby/blob/trunk/parse.y#L10469
 	dyna_pop_1(p);
 	if (!p->lvtbl->args) {
 	    struct local_vars *local = p->lvtbl->prev;
-	    xfree(p->lvtbl);
+	    ruby_sized_xfree(p->lvtbl, sizeof(*p->lvtbl));
 	    p->lvtbl = local;
 	}
     }
@@ -10817,7 +10817,7 @@ parser_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/parse.y#L10817
     struct local_vars *local, *prev;
 
     if (p->tokenbuf) {
-        xfree(p->tokenbuf);
+        ruby_sized_xfree(p->tokenbuf, p->toksiz);
     }
     for (local = p->lvtbl; local; local = prev) {
 	if (local->vars) xfree(local->vars);

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

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