]> sjero.net Git - wget/commitdiff
Minor formatting adjustments.
authorMicah Cowan <micah@cowan.name>
Sat, 12 Apr 2008 20:09:43 +0000 (13:09 -0700)
committerMicah Cowan <micah@cowan.name>
Sat, 12 Apr 2008 20:09:43 +0000 (13:09 -0700)
src/ChangeLog
src/utils.c

index a2881858a155dea184a5b37794484047714eec2d..4da5e1d3319764cf773bfb992e748f0142536a18 100644 (file)
@@ -1,3 +1,10 @@
+2008-04-12  Micah Cowan  <micah@cowan.name>
+
+       * utils.c (aprintf): Minor formatting changes to Alex's code (80-
+       column limit, concatenated string literals, avoiding nesting
+       levels), and removed invocation of free (since we're aborting
+       anyway).
+
 2008-04-11  Alexander Dergachev  <cy6erbr4in@gmail.com>
 
        * utils.c (aprintf): Now we are setting limits (1 Mb) for text
index af621402caa4d1c5d4f3d39d4e84e69ba5f30f04..f4e56d82af72d69c17120cac6728930259571767 100644 (file)
@@ -178,7 +178,8 @@ aprintf (const char *fmt, ...)
   ret = vasprintf (&str, fmt, args);
   va_end (args);
   if (ret < 0 && errno == ENOMEM)
-    memfatal ("aprintf", UNKNOWN_ATTEMPTED_SIZE);  /* for consistency with xmalloc/xrealloc */
+    memfatal ("aprintf", UNKNOWN_ATTEMPTED_SIZE);  /* for consistency
+                                                      with xmalloc/xrealloc */
   else if (ret < 0)
     return NULL;
   return str;
@@ -208,19 +209,20 @@ aprintf (const char *fmt, ...)
       /* Else try again with a larger buffer. */
       if (n > -1)               /* C99 */
         size = n + 1;           /* precisely what is needed */
+      else if (size >= FMT_MAX_LENGTH)  /* We have a huge buffer, */
+        {                               /* maybe we have some wrong
+                                           format string? */
+          logprintf (LOG_ALWAYS, 
+                     _("%s: aprintf: text buffer is too big (%ld bytes), "
+                       "aborting.\n"),
+                     exec_name, size);  /* printout a log message */
+          abort ();                     /* and abort... */
+        }
       else
         {
-          if (size >= FMT_MAX_LENGTH)  /* We have a huge buffer, */
-            {                          /* maybe we have some wrong format string? */
-              free (str);              /* In this case we must free already allocated memory, */
-              logprintf (LOG_ALWAYS, 
-                         _("%s: aprintf: text buffer is too big (%ld bytes), \
-free already allocated memory and abort.\n"),
-                         exec_name, size);  /* printout a log message */
-              abort ();             /* and abort... */
-            }
-                                       /* else, we continue to grow our buffer. */
-          size <<= 1;                  /* twice the old size */
+          /* else, we continue to grow our
+           * buffer: Twice the old size. */
+          size <<= 1;
         }
       str = xrealloc (str, size);
     }