ftpd: switch to mallced "globals"
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 4 Feb 2018 17:32:21 +0000 (18:32 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 4 Feb 2018 17:32:21 +0000 (18:32 +0100)
function                                             old     new   delta
cmdio_write_ok                                        45      49      +4
cmdio_write_error                                     45      49      +4
handle_dir_common                                    360     363      +3
handle_cwd                                            40      43      +3
port_or_pasv_was_seen                                 37      39      +2
pasv_active                                           13      15      +2
cmdio_write_raw                                       34      36      +2
cmdio_write                                           78      80      +2
get_remote_transfer_fd                                94      93      -1
port_pasv_cleanup                                     50      45      -5
bind_for_passive_mode                                124     119      -5
cmdio_get_cmd_and_arg                                237     230      -7
timeout_handler                                      104      93     -11
ftpd_main                                           2222    2152     -70
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/6 up/down: 22/-99)            Total: -77 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/ftpd.c

index 8af5acac296dde5217cc40955f1284e6be8fdfa1..833507ba1d1feab13bed1d1df7159deddd8906d4 100644 (file)
@@ -171,9 +171,13 @@ struct globals {
        char msg_ok [(sizeof("NNN " MSG_OK ) + 3) & 0xfffc];
        char msg_err[(sizeof("NNN " MSG_ERR) + 3) & 0xfffc];
 } FIX_ALIASING;
-#define G (*(struct globals*)bb_common_bufsiz1)
+#define G (*ptr_to_globals)
+/* ^^^ about 75 bytes smaller code than this: */
+//#define G (*(struct globals*)bb_common_bufsiz1)
 #define INIT_G() do { \
-       setup_common_bufsiz(); \
+       SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
+       /*setup_common_bufsiz();*/ \
+       \
        /* Moved to main */ \
        /*strcpy(G.msg_ok  + 4, MSG_OK );*/ \
        /*strcpy(G.msg_err + 4, MSG_ERR);*/ \