cli/lightning-cli: free eveything on exit.

It's not required, but it means valgrind won't complain about leaks.

Suggested-by: @m-schmoock
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-06-04 03:56:25 +09:30
parent 628b65fb40
commit e902d9af56
2 changed files with 11 additions and 0 deletions

View File

@ -604,6 +604,8 @@ int main(int argc, char *argv[])
tal_free(rpc_filename);
tal_free(ctx);
opt_free_table();
free(resp);
free(toks);
return 0;
}
@ -618,5 +620,7 @@ int main(int argc, char *argv[])
tal_free(rpc_filename);
tal_free(ctx);
opt_free_table();
free(resp);
free(toks);
return 1;
}

View File

@ -16,6 +16,7 @@ int test_getpid(void);
int test_printf(const char *format, ...);
void *test_malloc(size_t n);
void *test_realloc(void *p, size_t n);
void test_free(void *p);
#define main test_main
#define read test_read
@ -25,6 +26,7 @@ void *test_realloc(void *p, size_t n);
#define printf test_printf
#define malloc test_malloc
#define realloc test_realloc
#define free test_free
#include "../lightning-cli.c"
#undef main
@ -71,6 +73,11 @@ void *test_realloc(void *p, size_t n)
return p;
}
void test_free(void *p)
{
tal_free(p);
}
ssize_t test_read(int fd UNUSED, void *buf, size_t len)
{
if (len > max_read_return)