From 26085c8712c509d1384d1de99fec1bc9d3d15386 Mon Sep 17 00:00:00 2001 From: Jonathan Buchanan Date: Wed, 29 Jul 2020 18:23:51 -0400 Subject: remove allocations and pointers from claim token client/test code --- src/lib/merchant_api_post_order_claim.c | 6 +++--- src/lib/merchant_api_post_orders.c | 17 ++++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) (limited to 'src/lib') diff --git a/src/lib/merchant_api_post_order_claim.c b/src/lib/merchant_api_post_order_claim.c index 5ec2e243..58e2f4bf 100644 --- a/src/lib/merchant_api_post_order_claim.c +++ b/src/lib/merchant_api_post_order_claim.c @@ -185,7 +185,7 @@ TALER_MERCHANT_order_claim (struct GNUNET_CURL_Context *ctx, const char *backend_url, const char *order_id, const struct GNUNET_CRYPTO_EddsaPublicKey *nonce, - const struct TALER_ClaimTokenP *claim_token, + const struct TALER_ClaimTokenP claim_token, TALER_MERCHANT_OrderClaimCallback cb, void *cb_cls) { @@ -200,12 +200,12 @@ TALER_MERCHANT_order_claim (struct GNUNET_CURL_Context *ctx, GNUNET_break (0); return NULL; } - if (NULL != claim_token) + if (0 != GNUNET_is_zero (&claim_token)) { GNUNET_assert (0 == json_object_set_new (req_obj, "token", - GNUNET_JSON_from_data_auto (claim_token))); + GNUNET_JSON_from_data_auto (&claim_token))); } och = GNUNET_new (struct TALER_MERCHANT_OrderClaimHandle); och->ctx = ctx; diff --git a/src/lib/merchant_api_post_orders.c b/src/lib/merchant_api_post_orders.c index 1dafeb7f..e7f83ef3 100644 --- a/src/lib/merchant_api_post_orders.c +++ b/src/lib/merchant_api_post_orders.c @@ -87,7 +87,7 @@ handle_post_order_finished (void *cls, { struct TALER_MERCHANT_PostOrdersOperation *po = cls; const char *order_id = NULL; - struct TALER_ClaimTokenP token; + struct TALER_ClaimTokenP token = {0}; const json_t *json = response; struct TALER_MERCHANT_HttpResponse hr = { .http_status = (unsigned int) response_code, @@ -170,15 +170,10 @@ handle_post_order_finished (void *cls, GNUNET_break_op (0); break; } - { - const struct TALER_ClaimTokenP *token_ptr = &token; - if (!has_token) - token_ptr = NULL; - po->cb (po->cb_cls, - &hr, - order_id, - token_ptr); - } + po->cb (po->cb_cls, + &hr, + order_id, + token); if (MHD_HTTP_OK == response_code) GNUNET_JSON_parse_free (spec); TALER_MERCHANT_orders_post_cancel (po); @@ -334,7 +329,7 @@ TALER_MERCHANT_orders_post2 ( "lock_uuids", ua)); } - if (true != create_token) + if (! create_token) { GNUNET_assert (0 == json_object_set_new (req, -- cgit v1.2.3