X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Futils.c;h=a6c84491605517a8f0af7637ff681c70e943340f;hb=e72b57629bf49cdfd663002a8bb336a67b958979;hp=d1366ef9e1ee84a1b8b98e21e935a454ed168e37;hpb=76780021d822779f839bbf85883292e15eb3f587;p=wget diff --git a/src/utils.c b/src/utils.c index d1366ef9..a6c84491 100644 --- a/src/utils.c +++ b/src/utils.c @@ -28,8 +28,6 @@ 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. */ -#define USE_GNULIB_ALLOC - #include "wget.h" #include @@ -90,6 +88,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 * @@ -2207,6 +2231,8 @@ test_dir_matches_p() { { "*/*COMPLETE", NULL, NULL }, "foo/!COMPLETE", true }, { { "/dir with spaces", NULL, NULL }, "dir with spaces", true }, { { "/dir*with*spaces", NULL, NULL }, "dir with spaces", true }, + { { "/Tmp/has", NULL, NULL }, "/Tmp/has space", false }, + { { "/Tmp/has", NULL, NULL }, "/Tmp/has,comma", false }, }; for (i = 0; i < countof(test_array); ++i)