ftpd: switch to mallced "globals"

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>
This commit is contained in:
Denys Vlasenko 2018-02-04 18:32:21 +01:00
parent 2598915d43
commit 565af23222

View 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);*/ \