summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-06-20 14:07:01 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-06-20 14:07:01 +0200
commitd5684648f9e47fd49f8c699191b8740de783b1b8 (patch)
treee8e9fee8a0c9ba08a332cecde2ca072bddb0a442 /src
parent3a303770b4b0c1444db0bb89ecd6e2adc05e898e (diff)
downloadexchange-d5684648f9e47fd49f8c699191b8740de783b1b8.tar.gz
exchange-d5684648f9e47fd49f8c699191b8740de783b1b8.tar.bz2
exchange-d5684648f9e47fd49f8c699191b8740de783b1b8.zip
Batch CMD needs to memcpy CMDs in its internal status.
Diffstat (limited to 'src')
-rw-r--r--src/exchange-lib/testing_api_cmd_batch.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/exchange-lib/testing_api_cmd_batch.c b/src/exchange-lib/testing_api_cmd_batch.c
index 84cc308f6..1ebaa7948 100644
--- a/src/exchange-lib/testing_api_cmd_batch.c
+++ b/src/exchange-lib/testing_api_cmd_batch.c
@@ -34,7 +34,7 @@
struct BatchState
{
/* CMDs batch. */
- const struct TALER_TESTING_Command *batch;
+ struct TALER_TESTING_Command *batch;
/* Internal comand pointer. */
unsigned int batch_ip;
@@ -57,7 +57,10 @@ batch_run (void *cls,
/* hit end command, leap to next top-level command. */
if (NULL == bs->batch[bs->batch_ip].label)
+ {
TALER_TESTING_interpreter_next (is);
+ return;
+ }
bs->batch[bs->batch_ip].run (bs->batch[bs->batch_ip].cls,
&bs->batch[bs->batch_ip],
@@ -84,6 +87,7 @@ batch_cleanup (void *cls,
i++)
bs->batch[i].cleanup (bs->batch[i].cls,
&bs->batch[i]);
+ GNUNET_free_non_null (bs->batch);
}
@@ -105,9 +109,20 @@ TALER_TESTING_cmd_batch (const char *label,
{
struct TALER_TESTING_Command cmd;
struct BatchState *bs;
+ unsigned int i;
bs = GNUNET_new (struct BatchState);
- bs->batch = batch;
+
+ /* Get number of commands. */
+ for (i=0;NULL != batch[i].label;i++)
+ /* noop */
+ ;
+
+ bs->batch = GNUNET_new_array (i + 1,
+ struct TALER_TESTING_Command);
+ memcpy (bs->batch,
+ batch,
+ sizeof (struct TALER_TESTING_Command) * i);
cmd.cls = bs;
cmd.label = label;