gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-merchant] branch master updated: json_copy-ing a 'co


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: json_copy-ing a 'const json_t *' in order to call 'json_object_del()' on its copy.
Date: Mon, 13 Mar 2017 11:27:05 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new a093c87  json_copy-ing a 'const json_t *' in order to call 
'json_object_del()' on its copy.
a093c87 is described below

commit a093c87917fb1d56a4d7e6b73c0f9f241d145770
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Mar 13 11:25:17 2017 +0100

    json_copy-ing a 'const json_t *' in order to call 'json_object_del()'
    on its copy.
---
 src/backend/taler-merchant-httpd_track-transfer.c | 23 ++++++++++++++---------
 1 file 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 c3be4fd..1bf48ef 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;
 }
 
 /**

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]