Browse Source

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>
htlc_accepted_hook
Rusty Russell 6 years ago
parent
commit
e902d9af56
  1. 4
      cli/lightning-cli.c
  2. 7
      cli/test/run-large-input.c

4
cli/lightning-cli.c

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

7
cli/test/run-large-input.c

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

Loading…
Cancel
Save