Rename (almost) all destructors to destroy_<type>.

We usually did this, but sometimes they were named after what they did,
rather than what they cleaned up.

There are still a few exceptions:
1. I didn't bother creating destroy_xxx wrappers for htable routines
   which already existed.
2. Sometimes destructors really are used for side-effects (eg. to simply
   mark that something was freed): these are clearer with boutique names.
3. Generally destructors are static, but they don't need to be: in some
   cases we attach a destructor then remove it later, or only attach
   to *some* cases.  These are best with qualifiers in the destroy_<type>
   name.

Suggested-by: @ZmnSCPxj
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-02-14 12:23:13 +10:30
committed by Christian Decker
parent 6a3ccafaf9
commit 55d962046b
9 changed files with 26 additions and 23 deletions

View File

@@ -314,7 +314,7 @@ fail:
*
* We could queue this and wait for it to come back, but this is simple.
*/
static void hout_subd_died(struct htlc_out *hout)
static void destroy_hout_subd_died(struct htlc_out *hout)
{
log_debug(hout->key.channel->log,
"Failing HTLC %"PRIu64" due to peer death",
@@ -355,7 +355,7 @@ static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds,
local_fail_htlc(hout->in, failure_code,
hout->key.channel->scid);
/* Prevent hout from being failed twice. */
tal_del_destructor(hout, hout_subd_died);
tal_del_destructor(hout, destroy_hout_subd_died);
tal_free(hout);
return;
}
@@ -400,7 +400,7 @@ enum onion_type send_htlc_out(struct channel *out, u64 amount, u32 cltv,
/* Make peer's daemon own it, catch if it dies. */
hout = new_htlc_out(out->owner, out, amount, cltv,
payment_hash, onion_routing_packet, in);
tal_add_destructor(hout, hout_subd_died);
tal_add_destructor(hout, destroy_hout_subd_died);
msg = towire_channel_offer_htlc(out, amount, cltv, payment_hash,
onion_routing_packet);
@@ -894,7 +894,7 @@ static bool update_out_htlc(struct channel *channel,
/* First transition into commitment; now it outlives peer. */
if (newstate == SENT_ADD_COMMIT) {
tal_del_destructor(hout, hout_subd_died);
tal_del_destructor(hout, destroy_hout_subd_died);
tal_steal(ld, hout);
} else if (newstate == RCVD_REMOVE_ACK_REVOCATION) {