Fixes in refcnt

This commit is contained in:
vvaltman 2014-09-21 12:58:57 +04:00
parent 091b0608cb
commit 5212522336

View File

@ -1735,8 +1735,12 @@ void secret_chat_update_gw (struct tgl_secret_chat *U, unsigned flags) {
} }
void print_card_gw (void *extra, int success, int size, int *card) { void print_card_gw (void *extra, int success, int size, int *card) {
assert (success);
struct in_ev *ev = extra; struct in_ev *ev = extra;
if (ev && !--ev->refcnt) {
free (ev);
return;
}
if (!success) { return; }
mprint_start (ev); mprint_start (ev);
mprintf (ev, "Card: "); mprintf (ev, "Card: ");
int i; int i;
@ -1748,6 +1752,11 @@ void print_card_gw (void *extra, int success, int size, int *card) {
void callback_extf (void *extra, int success, char *buf) { void callback_extf (void *extra, int success, char *buf) {
struct in_ev *ev = extra; struct in_ev *ev = extra;
if (ev && !--ev->refcnt) {
free (ev);
return;
}
if (!success) { return; }
mprint_start (ev); mprint_start (ev);
mprintf (ev, "%s\n", buf); mprintf (ev, "%s\n", buf);
mprint_end (ev); mprint_end (ev);
@ -1794,7 +1803,9 @@ void interpreter_ex (char *line UU, void *ex) {
} }
if (*line == '(') { if (*line == '(') {
tgl_do_send_extf (line, strlen (line), callback_extf, ex); struct in_ev *ev = ex;
if (ev) { ev->refcnt ++; }
tgl_do_send_extf (line, strlen (line), callback_extf, ev);
in_readline = 0; in_readline = 0;
return; return;
} }