take: allocate temporary variables off NULL.

If we're going to simply take() a pointer, don't allocate it off a random
object.  Using NULL makes our intent clear, particularly with allocating
packets we're going to take() onto a queue.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-03-15 16:40:22 +10:30
parent 0a6e3d1e13
commit e63b7bb539
7 changed files with 76 additions and 76 deletions

View File

@@ -613,7 +613,7 @@ static bool process_getblockhash_for_txout(struct bitcoin_cli *bcli)
start_bitcoin_cli(bcli->bitcoind, NULL, process_getblock, false, cb, go,
"getblock",
take(tal_strndup(go, bcli->output,bcli->output_bytes)),
take(tal_strndup(NULL, bcli->output,bcli->output_bytes)),
NULL);
return true;
}
@@ -635,7 +635,7 @@ void bitcoind_getoutput_(struct bitcoind *bitcoind,
/* We may not have topology ourselves that far back, so ask bitcoind */
start_bitcoin_cli(bitcoind, NULL, process_getblockhash_for_txout,
true, cb, go,
"getblockhash", take(tal_fmt(go, "%u", blocknum)),
"getblockhash", take(tal_fmt(NULL, "%u", blocknum)),
NULL);
/* Looks like a leak, but we free it in process_getblock */