[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] branch master updated: remove allocations and pointers
From: |
gnunet |
Subject: |
[taler-merchant] branch master updated: remove allocations and pointers from claim token client/test code |
Date: |
Thu, 30 Jul 2020 00:24:01 +0200 |
This is an automated email from the git hooks/post-receive script.
jonathan-buchanan pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new 26085c8 remove allocations and pointers from claim token client/test
code
26085c8 is described below
commit 26085c8712c509d1384d1de99fec1bc9d3d15386
Author: Jonathan Buchanan <jonathan.russ.buchanan@gmail.com>
AuthorDate: Wed Jul 29 18:23:51 2020 -0400
remove allocations and pointers from claim token client/test code
---
src/include/taler_merchant_service.h | 6 +++---
src/lib/merchant_api_post_order_claim.c | 6 +++---
src/lib/merchant_api_post_orders.c | 17 ++++++-----------
src/testing/testing_api_cmd_claim_order.c | 8 +++++---
src/testing/testing_api_cmd_post_orders.c | 12 ++++--------
5 files changed, 21 insertions(+), 28 deletions(-)
diff --git a/src/include/taler_merchant_service.h
b/src/include/taler_merchant_service.h
index 783520c..f706ada 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -1114,7 +1114,7 @@ struct TALER_MERCHANT_PostOrdersOperation;
* @param cls closure
* @param hr HTTP response details
* @param order_id order id of the newly created order
- * @param token the claim token generated by the merchant (NULL if
+ * @param token the claim token generated by the merchant (zeroed if
* it wasn't generated).
*/
typedef void
@@ -1122,7 +1122,7 @@ typedef void
void *cls,
const struct TALER_MERCHANT_HttpResponse *hr,
const char *order_id,
- const struct TALER_ClaimTokenP *token);
+ struct TALER_ClaimTokenP token);
/**
@@ -1824,7 +1824,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);
diff --git a/src/lib/merchant_api_post_order_claim.c
b/src/lib/merchant_api_post_order_claim.c
index 5ec2e24..58e2f4b 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 1dafeb7..e7f83ef 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,
diff --git a/src/testing/testing_api_cmd_claim_order.c
b/src/testing/testing_api_cmd_claim_order.c
index ab95f59..ecdd107 100644
--- a/src/testing/testing_api_cmd_claim_order.c
+++ b/src/testing/testing_api_cmd_claim_order.c
@@ -187,9 +187,9 @@ order_claim_run (void *cls,
struct OrderClaimState *pls = cls;
const char *order_id;
const struct GNUNET_CRYPTO_EddsaPublicKey *nonce;
- const struct TALER_ClaimTokenP *claim_token;
- /* Only used if we do NOT use the nonce from traits. */
+ /* Only used if we do NOT use the nonce/token from traits. */
struct GNUNET_CRYPTO_EddsaPublicKey dummy_nonce;
+ struct TALER_ClaimTokenP claim_token = {0};
pls->is = is;
if (NULL != pls->order_id)
@@ -203,6 +203,7 @@ order_claim_run (void *cls,
else
{
const struct TALER_TESTING_Command *order_cmd;
+ const struct TALER_ClaimTokenP *ct;
order_cmd
= TALER_TESTING_interpreter_lookup_command (is,
@@ -222,10 +223,11 @@ order_claim_run (void *cls,
if (GNUNET_OK !=
TALER_TESTING_get_trait_claim_token (order_cmd,
0,
- &claim_token))
+ &ct))
{
TALER_TESTING_FAIL (is);
}
+ claim_token = *ct;
if (GNUNET_OK !=
TALER_TESTING_get_trait_order_id (order_cmd,
diff --git a/src/testing/testing_api_cmd_post_orders.c
b/src/testing/testing_api_cmd_post_orders.c
index 119245a..313be78 100644
--- a/src/testing/testing_api_cmd_post_orders.c
+++ b/src/testing/testing_api_cmd_post_orders.c
@@ -80,7 +80,7 @@ struct OrdersState
/**
* The claim token
*/
- struct TALER_ClaimTokenP *claim_token;
+ struct TALER_ClaimTokenP claim_token;
/**
* URL of the merchant backend.
@@ -148,7 +148,7 @@ orders_traits (void *cls,
TALER_TESTING_make_trait_merchant_sig (0, &ps->merchant_sig),
TALER_TESTING_make_trait_merchant_pub (0, &ps->merchant_pub),
TALER_TESTING_make_trait_claim_nonce (0, &ps->nonce),
- TALER_TESTING_make_trait_claim_token (0, ps->claim_token),
+ TALER_TESTING_make_trait_claim_token (0, &ps->claim_token),
TALER_TESTING_trait_end ()
};
@@ -232,14 +232,12 @@ static void
order_cb (void *cls,
const struct TALER_MERCHANT_HttpResponse *hr,
const char *order_id,
- const struct TALER_ClaimTokenP *claim_token)
+ struct TALER_ClaimTokenP claim_token)
{
struct OrdersState *ps = cls;
ps->po = NULL;
- if (NULL != claim_token)
- ps->claim_token = GNUNET_memdup (claim_token,
- sizeof (struct TALER_ClaimTokenP));
+ ps->claim_token = claim_token;
if (ps->http_status != hr->http_status)
{
TALER_LOG_ERROR ("Given vs expected: %u(%d) vs %u\n",
@@ -529,8 +527,6 @@ orders_cleanup (void *cls,
json_decref (ps->contract_terms);
GNUNET_free (ps->order);
GNUNET_free_nz ((void *) ps->order_id);
- if (NULL != ps->claim_token)
- GNUNET_free (ps->claim_token);
GNUNET_free (ps);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-merchant] branch master updated: remove allocations and pointers from claim token client/test code,
gnunet <=