summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2017-03-13 11:25:17 +0100
committerMarcello Stanisci <marcello.stanisci@inria.fr>2017-03-13 11:25:17 +0100
commita093c87917fb1d56a4d7e6b73c0f9f241d145770 (patch)
tree43c2e73daf9713920ea03abe513d7c87142cfd53 /src/backend
parent52eef77057a14203cdea8631746060ed2ad2ef3c (diff)
downloadmerchant-a093c87917fb1d56a4d7e6b73c0f9f241d145770.tar.gz
merchant-a093c87917fb1d56a4d7e6b73c0f9f241d145770.tar.bz2
merchant-a093c87917fb1d56a4d7e6b73c0f9f241d145770.zip
json_copy-ing a 'const json_t *' in order to call 'json_object_del()'
on its copy.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/taler-merchant-httpd_track-transfer.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/backend/taler-merchant-httpd_track-transfer.c b/src/backend/taler-merchant-httpd_track-transfer.c
index c3be4fd7..1bf48efb 100644
--- a/src/backend/taler-merchant-httpd_track-transfer.c
+++ b/src/backend/taler-merchant-httpd_track-transfer.c
@@ -209,9 +209,9 @@ hashmap_free (void *cls,
* GNUNET_NO otherwise.
*/
int
-build_response (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
+build_deposits_response (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
json_t *response = cls;
json_t *element;
@@ -242,9 +242,10 @@ build_response (void *cls,
json_t *
transform_response (const json_t *result)
{
- json_t *response = NULL;
- json_t *value;
json_t *deposits;
+ json_t *value;
+ json_t *result_mod = NULL;
+ json_t *deposits_response;
size_t index;
const char *key;
struct GNUNET_HashCode h_key;
@@ -265,6 +266,7 @@ transform_response (const json_t *result)
};
map = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
+ deposits = json_object_get (result, "deposits");
json_array_foreach (deposits, index, value)
{
@@ -310,11 +312,14 @@ transform_response (const json_t *result)
}
- response = json_array ();
+ deposits_response = json_array ();
GNUNET_CONTAINER_multihashmap_iterate (map,
- build_response,
- response);
+ build_deposits_response,
+ deposits_response);
+ result_mod = json_copy ((struct json_t *) result);
+ json_object_del (result_mod, "deposits");
+ json_object_set (result_mod, "deposits", deposits_response);
/**
* Missing actions:
@@ -334,7 +339,7 @@ transform_response (const json_t *result)
NULL);
GNUNET_JSON_parse_free (spec);
GNUNET_CONTAINER_multihashmap_destroy (map);
- return response;
+ return result_mod;
}
/**