From 766fb6e2821dc84ccfe290e8906f12001e34043b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 11 Jun 2016 18:22:33 +0200 Subject: fixing more leaks --- src/wire/plugin_wire_test.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'src/wire/plugin_wire_test.c') diff --git a/src/wire/plugin_wire_test.c b/src/wire/plugin_wire_test.c index da24a49b..4e91dade 100644 --- a/src/wire/plugin_wire_test.c +++ b/src/wire/plugin_wire_test.c @@ -381,6 +381,24 @@ struct BufFormatP GNUNET_NETWORK_STRUCT_END +/** + * Abort preparation of a wire transfer. For example, + * because we are shutting down. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param pth preparation to cancel + */ +static void +test_prepare_wire_transfer_cancel (void *cls, + struct TALER_WIRE_PrepareHandle *pth) +{ + if (NULL != pth->task) + GNUNET_SCHEDULER_cancel (pth->task); + json_decref (pth->wire); + GNUNET_free (pth); +} + + /** * Prepare for exeuction of a wire transfer. Calls the * callback with the serialized state. @@ -405,7 +423,8 @@ do_prepare (void *cls) pth->ptc (pth->ptc_cls, NULL, 0); - GNUNET_free (pth); + test_prepare_wire_transfer_cancel (NULL, + pth); return; } len = strlen (wire_enc) + 1; @@ -429,7 +448,8 @@ do_prepare (void *cls) } free (wire_enc); /* not using GNUNET_free(), as this one is allocated by libjansson */ - GNUNET_free (pth); + test_prepare_wire_transfer_cancel (NULL, + pth); } @@ -469,8 +489,7 @@ test_prepare_wire_transfer (void *cls, } pth = GNUNET_new (struct TALER_WIRE_PrepareHandle); pth->tc = tc; - pth->wire = (json_t *) wire; - json_incref (pth->wire); + pth->wire = json_incref ((json_t *) wire); pth->wtid = *wtid; pth->ptc = ptc; pth->ptc_cls = ptc_cls; @@ -481,23 +500,6 @@ test_prepare_wire_transfer (void *cls, } -/** - * Abort preparation of a wire transfer. For example, - * because we are shutting down. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param pth preparation to cancel - */ -static void -test_prepare_wire_transfer_cancel (void *cls, - struct TALER_WIRE_PrepareHandle *pth) -{ - GNUNET_SCHEDULER_cancel (pth->task); - json_decref (pth->wire); - GNUNET_free (pth); -} - - /** * Called with the result of submitting information about an incoming * transaction to a bank. -- cgit v1.2.3