From df06d0858b0f36ff03d87f521417ce1f9b8e948d Mon Sep 17 00:00:00 2001 From: Vysheng Date: Tue, 23 Sep 2014 17:18:42 +0400 Subject: [PATCH] Some more clear --- interface.c | 4 ++++ loop.c | 18 +++++++++--------- mtproto-client.c | 4 ++++ mtproto-client.h | 1 + structures.c | 3 +++ 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/interface.c b/interface.c index 92c48ed..17cafd3 100644 --- a/interface.c +++ b/interface.c @@ -967,6 +967,7 @@ extern char *downloads_directory; extern char *config_directory; extern char *binlog_file_name; extern char *lua_file; +extern struct event *term_ev; void do_clear (int arg_num, struct arg args[], struct in_ev *ev) { tgl_free_all (); @@ -980,6 +981,9 @@ void do_clear (int arg_num, struct arg args[], struct in_ev *ev) { free (config_directory); free (binlog_file_name); free (lua_file); + clear_history (); + event_free (term_ev); + event_base_free (tgl_state.ev_base); do_halt (0); } diff --git a/loop.c b/loop.c index 3429273..d4c8a2e 100644 --- a/loop.c +++ b/loop.c @@ -153,28 +153,28 @@ static void stdin_read_callback_line (evutil_socket_t fd, short what, void *arg) stdin_read_callback_all (2, what, arg); } +struct event *term_ev = 0; void net_loop (int flags, int (*is_end)(void)) { delete_stdin_event = 0; if (verbosity >= E_DEBUG) { logprintf ("Starting netloop\n"); } - struct event *ev = 0; if (flags & 3) { if (flags & 1) { - ev = event_new (tgl_state.ev_base, 0, EV_READ | EV_PERSIST, stdin_read_callback_char, 0); + term_ev = event_new (tgl_state.ev_base, 0, EV_READ | EV_PERSIST, stdin_read_callback_char, 0); } else { - ev = event_new (tgl_state.ev_base, 0, EV_READ | EV_PERSIST, stdin_read_callback_line, 0); + term_ev = event_new (tgl_state.ev_base, 0, EV_READ | EV_PERSIST, stdin_read_callback_line, 0); } - event_add (ev, 0); + event_add (term_ev, 0); } int last_get_state = time (0); while (!is_end || !is_end ()) { event_base_loop (tgl_state.ev_base, EVLOOP_ONCE); - if (ev && delete_stdin_event) { - event_free (ev); - ev = 0; + if (term_ev && delete_stdin_event) { + event_free (term_ev); + term_ev = 0; } #ifdef USE_LUA @@ -202,8 +202,8 @@ void net_loop (int flags, int (*is_end)(void)) { } } - if (ev) { - event_free (ev); + if (term_ev) { + event_free (term_ev); } if (verbosity >= E_DEBUG) { diff --git a/mtproto-client.c b/mtproto-client.c index 81d6dd9..f2aff8a 100644 --- a/mtproto-client.c +++ b/mtproto-client.c @@ -1443,3 +1443,7 @@ void tgls_free_dc (struct tgl_dc *DC) { if (DC->ev) { event_free (DC->ev); } tfree (DC, sizeof (*DC)); } + +void tgls_free_pubkey (void) { + RSA_free (pubKey); +} diff --git a/mtproto-client.h b/mtproto-client.h index ffc25b1..65212de 100644 --- a/mtproto-client.h +++ b/mtproto-client.h @@ -56,4 +56,5 @@ void tgln_insert_msg_id (struct tgl_session *S, long long id); void tglmp_on_start (void); void tgl_dc_authorize (struct tgl_dc *DC); void tgls_free_dc (struct tgl_dc *DC); +void tgls_free_pubkey (void); #endif diff --git a/structures.c b/structures.c index 15a24fc..9240018 100644 --- a/structures.c +++ b/structures.c @@ -30,6 +30,7 @@ #include "tree.h" #include "loop.h" #include +#include #include #include "queries.h" #include "binlog.h" @@ -1882,6 +1883,8 @@ void tgl_free_all (void) { for (i = 0; i <= tgl_state.max_dc_num; i++) if (tgl_state.DC_list[i]) { tgls_free_dc (tgl_state.DC_list[i]); } + BN_CTX_free (tgl_state.BN_ctx); + tgls_free_pubkey (); } int tgl_print_stat (char *s, int len) {