commit 63c64f0bd49165cebc77a15aafb836e396ac789a
parent 7aed390c8b79f338a70ce015e54229983bbf06fc
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date: Thu, 8 Mar 2018 17:06:46 +0100
avoid duplicating tokenized string.
Diffstat:
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/src/twister/taler-twister-service.c b/src/twister/taler-twister-service.c
@@ -810,7 +810,10 @@ con_val_iter (void *cls,
/**
* Delete object within the proxied response.
- * Always queues a response
+ * Always queues a response; only deletes the object if it is
+ * found within the response, otherwise return it verbatim (but
+ * will look for it into the next response). Will flush the
+ * operation once the wanted object has been found.
*
* @return MHD_YES / MHD_NO depending on successful / failing
* response queueing.
@@ -823,7 +826,6 @@ delete_object (struct MHD_Connection *con,
json_t *element;
json_t *cur;
json_error_t error;
- char *delete_path_dup;
char *token;
char *last_token;
char *mod_body;
@@ -838,15 +840,9 @@ delete_object (struct MHD_Connection *con,
hr->response);
}
- /* unstable if not dup'd. XXX: to be tested again without.
- * To be freed. */
- delete_path_dup = GNUNET_strdup (delete_path);
+ last_token = strrchr (delete_path, '.') + 1;
/* Give first nondelim char. */
- last_token = strrchr (delete_path_dup, '.') + 1;
- TALER_LOG_DEBUG ("Last token: %s@%p\n",
- last_token,
- last_token);
- token = strtok (delete_path_dup, ".");
+ token = strtok (delete_path, ".");
element = parsed_response;
do
{
@@ -1194,13 +1190,8 @@ create_response (void *cls,
hack_response_code = 0; /* reset for next request */
}
- /* Empty the object pointed by `delete_path` ONLY IF
- it is found within this response, otherwise it leaves
- the response untouched. */
if ('\0' != delete_path[0])
- {
return delete_object (con, hr);
- }
/* response might have been modified. */
return MHD_queue_response (con,
@@ -1209,7 +1200,7 @@ create_response (void *cls,
}
-/* ******************** MHD HTTP setup and event loop ******************** */
+/* ************ MHD HTTP setup and event loop *************** */
/**