]> sjero.net Git - wget/commitdiff
Use Gnulib's alloc functions throughout the source.
authorSteven Schubiger <schubiger@gmail.com>
Fri, 18 Apr 2008 23:21:24 +0000 (01:21 +0200)
committerSteven Schubiger <schubiger@gmail.com>
Fri, 18 Apr 2008 23:21:24 +0000 (01:21 +0200)
33 files changed:
src/cmpt.c
src/connect.c
src/convert.c
src/cookies.c
src/ftp-basic.c
src/ftp-ls.c
src/ftp-opie.c
src/ftp.c
src/gen-md5.c
src/gnutls.c
src/hash.c
src/host.c
src/html-parse.c
src/html-url.c
src/http-ntlm.c
src/http.c
src/init.c
src/log.c
src/main.c
src/mswindows.c
src/netrc.c
src/openssl.c
src/progress.c
src/ptimer.c
src/recur.c
src/res.c
src/retr.c
src/snprintf.c
src/spider.c
src/test.c
src/url.c
src/utils.c
src/utils.h

index 499a0fe3644a7b942631c47739b50433c562c5f7..6726b7fc4ee46e210a6375088925d011e2a0619f 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index 2626ef3208dee2fe7054ba61db79b8d743370327..361eb56b787291f4d84038270cfe3c79ba42ce75 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index 69d713f812d1d68e31cb343d936f876bcf512c0d..9f60ae3a0b75f8e0e52d3234e1e3873dc0e644ed 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index bdc32745b9e2afeaefdfe2010793eb0ba6b7b199..1258472a13d1d6f02226e4030db417978a2c7668 100644 (file)
@@ -43,6 +43,8 @@ as that of the covered work.  */
    sites that do send Set-Cookie2 also emit Set-Cookie for
    compatibility.  */
 
+#define USE_GNULIB_ALLOC
+
 #include "wget.h"
 
 #include <stdio.h>
index 38f0069fa394637e58b990b33ea54add4785be74..9145fe7d5c662ab379c9c613008eea1ec14cb9a6 100644 (file)
@@ -28,6 +28,8 @@ 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 <assert.h>
index e050c5a25460a5444a032e0eaa83a6f1daff8f02..67e9bc513f6a73567de05b691f60d485904a723b 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index 546e2105d36a1c1572903f9805c477965d23d3aa..5d740a1f9d509845b60a176d32132b2f2a25826a 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index 645e565d8584a5f2394c4752d9f35a249b7ea092..134c925aebfe2ea9350b57b69ef22d7ff3851e0a 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -28,6 +28,8 @@ 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 <stdio.h>
index 833f3f28278e5a0e7a59dce891f5915d2f26ea0e..d4d5f5c2267ed86f14d5d76120f4e9ad03fdf454 100644 (file)
@@ -28,6 +28,8 @@ 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 "gen-md5.h"
index 57d4ad5c5dca739673df569f3adbc3ccf63fd68e..258c0156b133e82079053f2b725b4b7938d06900 100644 (file)
@@ -27,6 +27,8 @@ 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 <assert.h>
index 4697b779bf65ef1ba4ec99de4d8ff0d122e342d3..f8b3c11faa4242d463c2ddef7d35fb5988b6872f 100644 (file)
@@ -31,6 +31,8 @@ as that of the covered work.  */
 /* With -DSTANDALONE, this file can be compiled outside Wget source
    tree.  To test, also use -DTEST.  */
 
+#define USE_GNULIB_ALLOC
+
 #ifndef STANDALONE
 # include "wget.h"
 #endif
index 5a530221da17969cdd17ba42cbc86a305e699771..1b418ce3a677cd3bba254398dbcec4f944dbb497 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index ade82f2ba5ded805769a8d0555df2ba0b4cd9bb4..623b7fd8260f37719191ff073f8a0f07c07becf6 100644 (file)
@@ -89,6 +89,8 @@ as that of the covered work.  */
 /* To test as standalone, compile with `-DSTANDALONE -I.'.  You'll
    still need Wget headers to compile.  */
 
+#define USE_GNULIB_ALLOC
+
 #include "wget.h"
 
 #ifdef STANDALONE
@@ -100,6 +102,7 @@ as that of the covered work.  */
 #include <string.h>
 #include <assert.h>
 
+#include "utils.h"
 #include "html-parse.h"
 
 #ifdef STANDALONE
index e9f2773ab409eeabb49966fcc9f7a8e6fede8a39..717fe8c4daef79a3929b8bf1272b6ed62b3574f7 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index def832be9bc6975b9e73f4bc85237c5924dce8fb..321d70d2144517801aacace614cb05d2ce4abe64 100644 (file)
@@ -28,6 +28,8 @@ 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"
 
 /* NTLM details:
index c1049d8ce776bf7add63c8b1a66bc05e4c3841b7..84bbe2e0dc1df16813e2b441e31b6942211f05d4 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index e079df95d12d1b2ac4afd24fb98df1a035260a51..1a5171ce89299e6b6d640c0cbfc297908f16ea8b 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index f7b3dca86086d3e2e5b9e843c50e308cc9569f6d..077ebeb833847afe7b9cbcdca0bb0c1f2a7e2ce7 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -28,6 +28,8 @@ 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 <stdio.h>
index b1e99695f19f124bc45af691a145be5b9324bc98..04ff76f372d6eb7182c216ad08e3027b5536dc74 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index cdfea2d263390012a1a3ced53d7e47f6aa4e2064..c64da02699c4e7ec508bd85cc29e6886f578b4a3 100644 (file)
@@ -28,6 +28,8 @@ 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
+
 #define INHIBIT_WRAP /* avoid wrapping of socket, bind, ... */
 
 #include "wget.h"
index fea440d33eb60f7b1ac2a729d5136f3f9a72fbee..35163a61e9070b5d2cd879fb05a4ea11a465545c 100644 (file)
@@ -30,6 +30,8 @@ as that of the covered work.  */
 /* This file used to be kept in synch with the code in Fetchmail, but
    the latter has diverged since.  */
 
+#define USE_GNULIB_ALLOC
+
 #include "wget.h"
 
 #include <stdio.h>
index 03fb1810172b61b1ad4572cb0c05a65e6f7a7952..d35aba32502102740c9e7e9918a472101e082848 100644 (file)
@@ -29,6 +29,8 @@ 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 <assert.h>
index 8b9b1013a255668de285219819bbefc088a118e7..62e8d87dad544453e2d9b3b37b6c7da600ced6a1 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index 9edddd82cb572442c55124b289f83f98348d4c07..0f5b5db0c8d3309bbc09eadd790446ef0b5ec1a7 100644 (file)
@@ -50,6 +50,8 @@ as that of the covered work.  */
      double secs = ptimer_measure ();
      printf ("The loop took %.2fs\n", secs);  */
 
+#define USE_GNULIB_ALLOC
+
 #include "wget.h"
 
 #include <stdio.h>
@@ -71,6 +73,7 @@ as that of the covered work.  */
 # include <windows.h>
 #endif
 
+#include "utils.h"
 #include "ptimer.h"
 
 /* Depending on the OS, one and only one of PTIMER_POSIX,
index d1d0f18d2e08094b04ea5f8680f95cbee0ecf75d..a992230dd1e91fee00229e67b34f613f71fbce17 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index 8c35f0e1cfae726a877e23e12b4ac44256d940ff..94d9769ddabeb7d53f5878de71f4a8dc3ff1ebba 100644 (file)
--- a/src/res.c
+++ b/src/res.c
@@ -67,6 +67,8 @@ as that of the covered work.  */
    res_match_path, res_register_specs, res_get_specs, and
    res_retrieve_file.  */
 
+#define USE_GNULIB_ALLOC
+
 #include "wget.h"
 
 #include <stdio.h>
index 179430acf72b83454fa319e1f987ddc320860303..60d4c62969bc53cd74bc58068f80b74f4d0e13d8 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index f458981af8f65f0726a4d7e0d29133c0216b6509..2a8fc6e64dddf57024923341cded1bc99da69145 100644 (file)
@@ -87,6 +87,8 @@
  *
  **************************************************************/
 
+#define USE_GNULIB_ALLOC
+
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
index 08fefc9f353cb698a3321871dfe10f3a28322f40..702540934b706d04d787a26289babcba329df1b3 100644 (file)
@@ -27,6 +27,8 @@ 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 <stdio.h>
index 04658bc75e79a49ca5a2c359c16f361dcbcaf34a..d6a865921dc5284ab7c9b47aff6441f30f25b835 100644 (file)
@@ -27,6 +27,8 @@ 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 <stdio.h>
 
 #include "test.h"
index a561725a200db5bebc75d5284bdbdb21130c7ff9..997b1058c111a726fb21923bf562ee28fc3c548a 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -28,6 +28,8 @@ 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 <stdio.h>
index f3b4a60c3aa285a85430c22b724c6e953c772d57..d1366ef9e1ee84a1b8b98e21e935a454ed168e37 100644 (file)
@@ -28,6 +28,8 @@ 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 <stdio.h>
index 7d41b3148e5c3e011d9bcb1e27d9d95aca17e46c..bac112ed713d3e6cd7ffb2dd53f994550df35a25 100644 (file)
@@ -31,6 +31,32 @@ as that of the covered work.  */
 #ifndef UTILS_H
 #define UTILS_H
 
+#ifdef USE_GNULIB_ALLOC
+
+/* Constant is using when we don`t know attempted size exactly */
+#define UNKNOWN_ATTEMPTED_SIZE -3
+
+/* Macros that interface to malloc, but know about type sizes, and
+   cast the result to the appropriate type.  The casts are not
+   necessary in standard C, but Wget performs them anyway for the sake
+   of pre-standard environments and possibly C++.  */
+
+#define xnew(type) (xmalloc (sizeof (type)))
+#define xnew0(type) (xcalloc (1, sizeof (type)))
+#define xnew_array(type, len) (xmalloc ((len) * sizeof (type)))
+#define xnew0_array(type, len) (xcalloc ((len), sizeof (type)))
+
+#define alloca_array(type, size) ((type *) alloca ((size) * sizeof (type)))
+
+#define xfree free
+/* Free P if it is non-NULL.  C requires free() to behaves this way by
+   default, but Wget's code is historically careful not to pass NULL
+   to free.  This allows us to assert p!=NULL in xfree to check
+   additional errors.  (But we currently don't do that!)  */
+#define xfree_null(p) if (!(p)) ; else xfree (p)
+
+#endif /* USE_GNULIB_ALLOC */
+
 struct hash_table;
 
 struct file_memory {