From 71bb2d869202498a24fbb0a40787c912c971d2cb Mon Sep 17 00:00:00 2001
From: Nathan Froyd <froydnj@codesourcery.com>
Date: Fri, 20 Aug 2010 15:26:56 +0000
Subject: [PATCH] ggc-common.c (ggc_mark_root_tab): New function, split out
 from...

	* ggc-common.c (ggc_mark_root_tab): New function, split out from...
	(ggc_mark_roots): ...here.

From-SVN: r163407
---
 gcc/ChangeLog    |  5 +++++
 gcc/ggc-common.c | 25 +++++++++++++++----------
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1ab87d5c08c1..b1ad8511f2ff 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2010-08-20  Nathan Froyd  <froydnj@codesourcery.com>
+
+	* ggc-common.c (ggc_mark_root_tab): New function, split out from...
+	(ggc_mark_roots): ...here.
+
 2010-08-20  Nathan Froyd  <froydnj@codesourcery.com>
 
 	* vec.h (FOR_EACH_VEC_ELT): Define.
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index cb1b64576a02..5b66bb4fa597 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -147,14 +147,25 @@ ggc_scan_cache_tab (const_ggc_cache_tab_t ctp)
       }
 }
 
+/* Mark all the roots in the table RT.  */
+
+static void
+ggc_mark_root_tab (const_ggc_root_tab_t rt)
+{
+  size_t i;
+
+  for ( ; rt->base != NULL; rt++)
+    for (i = 0; i < rt->nelt; i++)
+      (*rt->cb) (*(void **) ((char *)rt->base + rt->stride * i));
+}
+
 /* Iterate through all registered roots and mark each element.  */
 
 void
 ggc_mark_roots (void)
 {
   const struct ggc_root_tab *const *rt;
-  const struct ggc_root_tab *rti;
-  const_ggc_root_tab_t rtp;
+  const_ggc_root_tab_t rtp, rti;
   const struct ggc_cache_tab *const *ct;
   const_ggc_cache_tab_t ctp;
   size_t i;
@@ -164,16 +175,10 @@ ggc_mark_roots (void)
       memset (rti->base, 0, rti->stride);
 
   for (rt = gt_ggc_rtab; *rt; rt++)
-    for (rti = *rt; rti->base != NULL; rti++)
-      for (i = 0; i < rti->nelt; i++)
-	(*rti->cb) (*(void **)((char *)rti->base + rti->stride * i));
+    ggc_mark_root_tab (*rt);
 
   FOR_EACH_VEC_ELT (const_ggc_root_tab_t, extra_root_vec, i, rtp)
-    {
-      for (rti = rtp; rti->base != NULL; rti++)
-        for (i = 0; i < rti->nelt; i++)
-          (*rti->cb) (*(void **) ((char *)rti->base + rti->stride * i));
-    }
+    ggc_mark_root_tab (rtp);
 
   if (ggc_protect_identifiers)
     ggc_mark_stringpool ();
-- 
GitLab