Skip to content

Commit

Permalink
Free messages exactly once
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWiederhake committed Aug 1, 2016
1 parent e4ebc9d commit 0e0ffe4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion structures.c
Original file line number Diff line number Diff line change
Expand Up @@ -2570,11 +2570,22 @@ void tgls_free_message_gw (struct tgl_message *M, void *TLS) {
tgls_free_message (TLS, M);
}

void tgls_remove_message_gw (struct tgl_state *TLS, struct tgl_message *M) {
if (tree_lookup_message (TLS->message_unsent_tree, M)) {
tglm_message_remove_unsent (TLS, M);
}
}

void tgls_remove_and_free_message_gw (struct tgl_message *M, void *TLS) {
tgls_remove_message_gw (TLS, M);
tgls_free_message (TLS, M);
}

void tgl_free_all (struct tgl_state *TLS) {
tree_act_ex_peer (TLS->peer_tree, tgls_free_peer_gw, TLS);
TLS->peer_tree = tree_clear_peer (TLS->peer_tree);
TLS->peer_by_name_tree = tree_clear_peer_by_name (TLS->peer_by_name_tree);
tree_act_ex_message (TLS->message_tree, tgls_free_message_gw, TLS);
tree_act_ex_message (TLS->message_tree, tgls_remove_and_free_message_gw, TLS);
TLS->message_tree = tree_clear_message (TLS->message_tree);
tree_act_ex_message (TLS->message_unsent_tree, tgls_free_message_gw, TLS);
TLS->message_unsent_tree = tree_clear_message (TLS->message_unsent_tree);
Expand Down

0 comments on commit 0e0ffe4

Please sign in to comment.