]> sjero.net Git - wget/commitdiff
Move memfatal() to utils.c.
authorSteven Schubiger <schubiger@gmail.com>
Sat, 19 Apr 2008 19:13:38 +0000 (21:13 +0200)
committerSteven Schubiger <schubiger@gmail.com>
Sat, 19 Apr 2008 19:13:38 +0000 (21:13 +0200)
src/utils.c

index d1366ef9e1ee84a1b8b98e21e935a454ed168e37..3459be913ee38e53c8db1342a26214dbd02448e0 100644 (file)
@@ -90,6 +90,32 @@ as that of the covered work.  */
 #include "test.h"
 #endif 
 
+static void
+memfatal (const char *context, long attempted_size)
+{
+  /* Make sure we don't try to store part of the log line, and thus
+     call malloc.  */
+  log_set_save_context (false);
+
+  /* We have different log outputs in different situations:
+     1) output without bytes information
+     2) output with bytes information  */
+  if (attempted_size == UNKNOWN_ATTEMPTED_SIZE)
+    {
+      logprintf (LOG_ALWAYS,
+                 _("%s: %s: Failed to allocate enough memory; memory exhausted.\n"),
+                 exec_name, context);
+    }
+  else
+    {
+      logprintf (LOG_ALWAYS,
+                 _("%s: %s: Failed to allocate %ld bytes; memory exhausted.\n"),
+                 exec_name, context, attempted_size);
+    }
+
+  exit (1);
+}
+
 /* Utility function: like xstrdup(), but also lowercases S.  */
 
 char *