* pretty-print.c: Don't include ggc.h.
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 26 May 2010 18:55:51 +0000 (18:55 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 26 May 2010 18:55:51 +0000 (18:55 +0000)
(identifier_to_locale_alloc, identifier_to_locale_free): Define.
(identifier_to_locale): Use them for allocation.
* pretty-print.h (identifier_to_locale_alloc,
identifier_to_locale_free): Declare.
* toplev.c (alloc_for_identifier_to_locale): New.
(general_init): Set identifier_to_locale_alloc and
identifier_to_locale_free.
* Makefile.in (pretty-print.o): Update dependencies.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159898 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/Makefile.in
gcc/pretty-print.c
gcc/pretty-print.h
gcc/toplev.c

index 91d39a2..e869925 100644 (file)
@@ -1,3 +1,15 @@
+2010-05-26  Joseph Myers  <joseph@codesourcery.com>
+
+       * pretty-print.c: Don't include ggc.h.
+       (identifier_to_locale_alloc, identifier_to_locale_free): Define.
+       (identifier_to_locale): Use them for allocation.
+       * pretty-print.h (identifier_to_locale_alloc,
+       identifier_to_locale_free): Declare.
+       * toplev.c (alloc_for_identifier_to_locale): New.
+       (general_init): Set identifier_to_locale_alloc and
+       identifier_to_locale_free.
+       * Makefile.in (pretty-print.o): Update dependencies.
+
 2010-05-26  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gimple.c (gimple_types_compatible_p): Return 0 for aggregate and
index bbb16f9..77b836f 100644 (file)
@@ -3398,8 +3398,7 @@ params.o : params.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(PARAMS_H) \
    $(TOPLEV_H)
 pointer-set.o: pointer-set.c pointer-set.h $(CONFIG_H) $(SYSTEM_H)
 hooks.o: hooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(HOOKS_H)
-pretty-print.o: $(CONFIG_H) $(SYSTEM_H) coretypes.h intl.h $(PRETTY_PRINT_H) \
-   $(GGC_H)
+pretty-print.o: $(CONFIG_H) $(SYSTEM_H) coretypes.h intl.h $(PRETTY_PRINT_H)
 errors.o : errors.c $(CONFIG_H) $(SYSTEM_H) errors.h $(BCONFIG_H)
 dbgcnt.o: dbgcnt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TOPLEV_H) $(DBGCNT_H) \
    $(TM_H) $(RTL_H) output.h
index af28387..aa8924c 100644 (file)
@@ -24,7 +24,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "intl.h"
 #include "pretty-print.h"
-#include "ggc.h"
 
 #if HAVE_ICONV
 #include <iconv.h>
@@ -857,14 +856,21 @@ decode_utf8_char (const unsigned char *p, size_t len, unsigned int *value)
     }
 }
 
+/* Allocator for identifier_to_locale and corresponding function to
+   free memory.  */
+
+void *(*identifier_to_locale_alloc) (size_t) = xmalloc;
+void (*identifier_to_locale_free) (void *) = free;
+
 /* Given IDENT, an identifier in the internal encoding, return a
    version of IDENT suitable for diagnostics in the locale character
-   set: either IDENT itself, or a garbage-collected string converted
-   to the locale character set and using escape sequences if not
-   representable in the locale character set or containing control
-   characters or invalid byte sequences.  Existing backslashes in
-   IDENT are not doubled, so the result may not uniquely specify the
-   contents of an arbitrary byte sequence identifier.  */
+   set: either IDENT itself, or a string, allocated using
+   identifier_to_locale_alloc, converted to the locale character set
+   and using escape sequences if not representable in the locale
+   character set or containing control characters or invalid byte
+   sequences.  Existing backslashes in IDENT are not doubled, so the
+   result may not uniquely specify the contents of an arbitrary byte
+   sequence identifier.  */
 
 const char *
 identifier_to_locale (const char *ident)
@@ -895,7 +901,7 @@ identifier_to_locale (const char *ident)
      outside printable ASCII.  */
   if (!valid_printable_utf8)
     {
-      char *ret = GGC_NEWVEC (char, 4 * idlen + 1);
+      char *ret = (char *) identifier_to_locale_alloc (4 * idlen + 1);
       char *p = ret;
       for (i = 0; i < idlen; i++)
        {
@@ -938,7 +944,7 @@ identifier_to_locale (const char *ident)
              size_t outbytesleft = ret_alloc - 1;
              size_t iconv_ret;
 
-             ret = GGC_NEWVEC (char, ret_alloc);
+             ret = (char *) identifier_to_locale_alloc (ret_alloc);
              outbuf = ret;
 
              if (iconv (cd, 0, 0, 0, 0) == (size_t) -1)
@@ -954,7 +960,7 @@ identifier_to_locale (const char *ident)
                  if (errno == E2BIG)
                    {
                      ret_alloc *= 2;
-                     ggc_free (ret);
+                     identifier_to_locale_free (ret);
                      ret = NULL;
                      continue;
                    }
@@ -975,7 +981,7 @@ identifier_to_locale (const char *ident)
                  if (errno == E2BIG)
                    {
                      ret_alloc *= 2;
-                     ggc_free (ret);
+                     identifier_to_locale_free (ret);
                      ret = NULL;
                      continue;
                    }
@@ -997,7 +1003,7 @@ identifier_to_locale (const char *ident)
 
   /* Otherwise, convert non-ASCII characters in IDENT to UCNs.  */
   {
-    char *ret = GGC_NEWVEC (char, 10 * idlen + 1);
+    char *ret = (char *) identifier_to_locale_alloc (10 * idlen + 1);
     char *p = ret;
     for (i = 0; i < idlen;)
       {
index c3c3e6d..a2e3c40 100644 (file)
@@ -339,5 +339,7 @@ pp_set_verbatim_wrapping_ (pretty_printer *pp)
 #define pp_set_verbatim_wrapping(PP) pp_set_verbatim_wrapping_ (pp_base (PP))
 
 extern const char *identifier_to_locale (const char *);
+extern void *(*identifier_to_locale_alloc) (size_t);
+extern void (*identifier_to_locale_free) (void *);
 
 #endif /* GCC_PRETTY_PRINT_H */
index 83008da..f22c4d5 100644 (file)
@@ -1668,6 +1668,14 @@ realloc_for_line_map (void *ptr, size_t len)
   return ggc_realloc (ptr, len);
 }
 
+/* A helper function: used as the allocator function for
+   identifier_to_locale.  */
+static void *
+alloc_for_identifier_to_locale (size_t len)
+{
+  return ggc_alloc (len);
+}
+
 /* Initialization of the front end environment, before command line
    options are parsed.  Signal handlers, internationalization etc.
    ARGV0 is main's argv[0].  */
@@ -1690,6 +1698,9 @@ general_init (const char *argv0)
 
   gcc_init_libintl ();
 
+  identifier_to_locale_alloc = alloc_for_identifier_to_locale;
+  identifier_to_locale_free = ggc_free;
+
   /* Initialize the diagnostics reporting machinery, so option parsing
      can give warnings and errors.  */
   diagnostic_initialize (global_dc, N_OPTS);