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

@@ -580,8 +580,8 @@ struct routing_channel *routing_channel_new(const tal_t *ctx,
return chan;
}
static void remove_connection_from_channel(struct node_connection *nc,
struct routing_state *rstate)
static void destroy_node_connection(struct node_connection *nc,
struct routing_state *rstate)
{
struct routing_channel *chan = uintmap_get(
&rstate->channels, short_channel_id_to_uint(&nc->short_channel_id));
@@ -600,7 +600,7 @@ void channel_add_connection(struct routing_state *rstate,
int direction = get_channel_direction(&nc->src->id, &nc->dst->id);
assert(chan != NULL);
chan->connections[direction] = nc;
tal_add_destructor2(nc, remove_connection_from_channel, rstate);
tal_add_destructor2(nc, destroy_node_connection, rstate);
}
static void add_pending_node_announcement(struct routing_state *rstate, struct pubkey *nodeid)