common: assert that they don't call setup_tmpctx() twice.
Otherwise, leaks will occur. And fix up dualopend and devtool/route, which do this! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <assert.h>
|
||||||
#include <bitcoin/chainparams.h>
|
#include <bitcoin/chainparams.h>
|
||||||
#include <ccan/list/list.h>
|
#include <ccan/list/list.h>
|
||||||
#include <ccan/mem/mem.h>
|
#include <ccan/mem/mem.h>
|
||||||
@@ -99,6 +100,8 @@ void setup_locale(void)
|
|||||||
/* Initial creation of tmpctx. */
|
/* Initial creation of tmpctx. */
|
||||||
void setup_tmpctx(void)
|
void setup_tmpctx(void)
|
||||||
{
|
{
|
||||||
|
/* Don't call me twice! */
|
||||||
|
assert(!tmpctx);
|
||||||
tmpctx = tal_arr_label(NULL, char, 0, "tmpctx");
|
tmpctx = tal_arr_label(NULL, char, 0, "tmpctx");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,6 @@ static struct route_hop *least_cost(struct gossmap *map,
|
|||||||
struct route_hop *path;
|
struct route_hop *path;
|
||||||
struct timemono tstart, tstop;
|
struct timemono tstart, tstop;
|
||||||
|
|
||||||
setup_locale();
|
|
||||||
setup_tmpctx();
|
|
||||||
|
|
||||||
tstart = time_mono();
|
tstart = time_mono();
|
||||||
dij = dijkstra(tmpctx, map, dst,
|
dij = dijkstra(tmpctx, map, dst,
|
||||||
sent, riskfactor, route_can_carry,
|
sent, riskfactor, route_can_carry,
|
||||||
|
|||||||
@@ -4334,7 +4334,7 @@ static void fetch_per_commitment_point(u32 point_count,
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
common_setup(argv[0]);
|
setup_locale();
|
||||||
|
|
||||||
struct pollfd pollfd[2];
|
struct pollfd pollfd[2];
|
||||||
struct state *state = tal(NULL, struct state);
|
struct state *state = tal(NULL, struct state);
|
||||||
|
|||||||
Reference in New Issue
Block a user