Comments
Patch
@@ -89,6 +89,8 @@ along with GCC; see the file COPYING3. If not see
declarations for e.g. AIX 4.x. */
#endif
+#include <new>
+
static void general_init (const char *);
static void do_compile (void);
static void process_options (void);
@@ -1061,6 +1063,21 @@ open_auxiliary_file (const char *ext)
return file;
}
+
+/* Error handler for use with C++ memory allocation. Will be
+ installed via std::set_new_handler(). */
+
+static void
+cxx_out_of_memory()
+{
+ fprintf (stderr,
+ "\n%s%sout of memory\n",
+ progname, *progname ? ": " : "");
+
+ xexit (1);
+}
+
+
/* Initialization of the front end environment, before command line
options are parsed. Signal handlers, internationalization etc.
ARGV0 is main's argv[0]. */
@@ -1074,6 +1091,8 @@ general_init (const char *argv0)
--p;
progname = p;
+ std::set_new_handler (cxx_out_of_memory);
+
xmalloc_set_program_name (progname);
hex_init ();