wget: if FEATURE_CLEAN_UP, free(ptr_to_globals)
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Wed, 16 Oct 2013 12:43:30 +0000 (14:43 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 16 Oct 2013 12:43:30 +0000 (14:43 +0200)
Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
include/libbb.h
networking/wget.c

index 3ab1d6b46090768506558733ec5a0c9b40375548..c965461097253cabe50654ae240ae0e700491511 100644 (file)
@@ -1773,6 +1773,11 @@ extern struct globals *const ptr_to_globals;
        (*(struct globals**)&ptr_to_globals) = (void*)(x); \
        barrier(); \
 } while (0)
+#define FREE_PTR_TO_GLOBALS() do { \
+       if (ENABLE_FEATURE_CLEAN_UP) { \
+               free(ptr_to_globals); \
+       } \
+} while (0)
 
 /* You can change LIBBB_DEFAULT_LOGIN_SHELL, but don't use it,
  * use bb_default_login_shell and following defines.
index a32f8522939a16897e38912a91373cece8a30967..cfbacecede849884335dbbf94125bdfa1cabdde7 100644 (file)
@@ -89,6 +89,9 @@ struct globals {
 #define INIT_G() do { \
        SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
 } while (0)
+#define FINI_G() do { \
+       FREE_PTR_TO_GLOBALS(); \
+} while (0)
 
 
 /* Must match option string! */
@@ -1013,5 +1016,10 @@ int wget_main(int argc UNUSED_PARAM, char **argv)
        if (G.output_fd >= 0)
                xclose(G.output_fd);
 
+#if ENABLE_FEATURE_CLEAN_UP && ENABLE_FEATURE_WGET_LONG_OPTIONS
+       free(G.extra_headers);
+#endif
+       FINI_G();
+
        return EXIT_SUCCESS;
 }