mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-23 15:04:19 +01:00
utils: add a global tmpctx.
I did a brief audit of tmpctx uses, and we do leak them in various corner cases. Fortunely, all our daemons are based on some kind of I/O loop, so it's fairly easy to clean a global tmpctx at that point. This makes things a bit neater, and slightly more efficient, but also clearer: I avoided creating a tmpctx in a few places because I didn't want to add another allocation. With that penalty removed, I can use it more freely and hopefully write clearer code. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -195,7 +195,8 @@ static u8 *opening_read_peer_msg(struct state *state)
|
||||
&state->channel_id,
|
||||
sync_crypto_write_arg,
|
||||
status_fail_io,
|
||||
state)) == NULL);
|
||||
state)) == NULL)
|
||||
clean_tmpctx();
|
||||
|
||||
return msg;
|
||||
}
|
||||
@@ -772,6 +773,7 @@ int main(int argc, char *argv[])
|
||||
status_trace("Sent %s with fd",
|
||||
opening_wire_type_name(fromwire_peektype(msg)));
|
||||
tal_free(state);
|
||||
tal_free(tmpctx);
|
||||
return 0;
|
||||
}
|
||||
#endif /* TESTING */
|
||||
|
||||
Reference in New Issue
Block a user