]> sjero.net Git - wget/blobdiff - src/xmalloc.c
Updated NEWS for 1.11.3.
[wget] / src / xmalloc.c
index 35f2c1993a0862200988e099ed13af88c6ad2418..aaf743df559bf05ee067e0960e4a9ce714b058b3 100644 (file)
@@ -1,5 +1,5 @@
 /* Wrappers around malloc and memory debugging support.
-   Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation,
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation,
    Inc.
 
 This file is part of GNU Wget.
@@ -28,7 +28,7 @@ Corresponding Source for a non-source form of such a combination
 shall include the source code for the parts of OpenSSL used as well
 as that of the covered work.  */
 
-#include <config.h>
+#include "wget.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -36,7 +36,6 @@ as that of the covered work.  */
 #include <errno.h>
 #include <assert.h>
 
-#include "wget.h"
 #include "xmalloc.h"
 #include "hash.h"               /* for hash_pointer */
 
@@ -54,15 +53,29 @@ as that of the covered work.  */
 /* Croak the fatal memory error and bail out with non-zero exit
    status.  */
 
-static void
+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);
-  logprintf (LOG_ALWAYS,
-             _("%s: %s: Failed to allocate %ld bytes; memory exhausted.\n"),
-             exec_name, context, attempted_size);
+
+  /* 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);
 }