aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFournier Nicolas <nicolas.fournier@ensta-paristech.fr>2015-06-12 15:28:49 +0200
committerFournier Nicolas <nicolas.fournier@ensta-paristech.fr>2015-06-12 15:28:49 +0200
commit6c440e0cec9b1faa0ae819e85f9974fddd38b9c2 (patch)
tree64af939f513464e445625a994d55c4f2cb518439
parentb1e0dd8b7ec7af8e478d67ef49c60bd2d0774864 (diff)
moving things around and fixing memory issues
-rw-r--r--src/mintdb/perf_taler_mintdb_init.c2
-rw-r--r--src/mintdb/perf_taler_mintdb_init.h48
-rw-r--r--src/mintdb/perf_taler_mintdb_interpreter.c18
-rw-r--r--src/mintdb/perf_taler_mintdb_interpreter.h18
4 files changed, 74 insertions, 12 deletions
diff --git a/src/mintdb/perf_taler_mintdb_init.c b/src/mintdb/perf_taler_mintdb_init.c
index b4add8d3f..f88695d83 100644
--- a/src/mintdb/perf_taler_mintdb_init.c
+++ b/src/mintdb/perf_taler_mintdb_init.c
@@ -376,6 +376,8 @@ PERF_TALER_MINTDB_coin_public_info_init ()
int
PERF_TALER_MINTDB_coin_public_info_free (struct TALER_CoinPublicInfo *cpi)
{
+ GNUNET_CRYPTO_rsa_signature_free (cpi->denom_sig.rsa_signature);
+ GNUNET_CRYPTO_rsa_public_key_free (cpi->denom_pub.rsa_public_key);
GNUNET_free (cpi);
return GNUNET_OK;
}
diff --git a/src/mintdb/perf_taler_mintdb_init.h b/src/mintdb/perf_taler_mintdb_init.h
index eef2165dc..14bbb2129 100644
--- a/src/mintdb/perf_taler_mintdb_init.h
+++ b/src/mintdb/perf_taler_mintdb_init.h
@@ -27,40 +27,86 @@
#define CURRENCY "EUR"
+/**
+ * @return a randomly generated CollectableBlindcoin
+ */
struct TALER_MINTDB_CollectableBlindcoin *
PERF_TALER_MINTDB_collectable_blindcoin_init (void);
+/**
+ * Liberate memory of @a coin
+ */
int
PERF_TALER_MINTDB_collectable_blindcoin_free (struct TALER_MINTDB_CollectableBlindcoin *NAME);
+/**
+ * @return a randomly generated reserve
+ */
struct TALER_MINTDB_Reserve *
PERF_TALER_MINTDB_reserve_init (void);
+/**
+ * Free memory of a reserve
+ */
int
PERF_TALER_MINTDB_reserve_free (struct TALER_MINTDB_Reserve *reserve);
+/**
+ * @return a randomly generated refresh session
+ */
struct TALER_MINTDB_RefreshSession *
PERF_TALER_MINTDB_refresh_session_init (void);
+/**
+ * Frees memory of a refresh_session
+ */
+int
+PERF_TALER_MINTDB_refresh_session_free (struct TALER_MINTDB_RefreshSession *refresh_session);
+
+
+/**
+ * Create a randomly generated deposit
+ */
struct TALER_MINTDB_Deposit *
PERF_TALER_MINTDB_deposit_init ();
+/**
+ * Free memory of a deposit
+ */
int
PERF_TALER_MINTDB_deposit_free (struct TALER_MINTDB_Deposit *deposit);
+/**
+ * Generate a randomly generate DenominationKeyInformation
+ */
struct TALER_MINTDB_DenominationKeyIssueInformation *
-PERF_TALER_MINTDB_init_denomination(void);
+PERF_TALER_MINTDB_denomination_init (void);
+/**
+ * Free memory for a DenominationKeyIssueInformation
+ */
int
PERF_TALER_MINTDB_denomination_free (struct TALER_MINTDB_DenominationKeyIssueInformation *dki);
+/**
+ * Generate a random CoinPublicInfo
+ */
+struct TALER_CoinPublicInfo *
+PERF_TALER_MINTDB_coin_public_info_init (void);
+
+
+/**
+ * Free a CoinPublicInfo
+ */
+int PERF_TALER_MINTDB_coin_public_info_free (struct TALER_CoinPublicInfo *cpi);
+
#endif
diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c
index 8efe0a771..ac2ea1e6e 100644
--- a/src/mintdb/perf_taler_mintdb_interpreter.c
+++ b/src/mintdb/perf_taler_mintdb_interpreter.c
@@ -135,7 +135,7 @@ static int
cmd_clean (struct PERF_TALER_MINTDB_Cmd cmd[])
{
int i = 0;
- for (i=0; PERF_TALER_MINTDB_CMD_END != cmd[i].command; i++)
+ for (i = 0; PERF_TALER_MINTDB_CMD_END != cmd[i].command; i++)
{
switch (cmd[i].command)
{
@@ -152,15 +152,12 @@ cmd_clean (struct PERF_TALER_MINTDB_Cmd cmd[])
cmd[i].details.save_array.data_saved = NULL;
}
- case PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT:
- PERF_TALER_MINTDB_deposit_free (cmd[i].exposed.deposit);
- break;
-
case PERF_TALER_MINTDB_CMD_LOAD_ARRAY:
GNUNET_free (cmd[i].details.load_array.permutation);
break;
default:
+ data_free (&cmd[i].exposed, cmd[i].exposed_type);
break;
}
@@ -178,15 +175,17 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
{
int jump = cmd_find (state->cmd,
state->cmd[state->i].details.end_loop.label_loop);
+
+ state->cmd[jump].details.loop.curr_iteration++;
// If the loop is not finished
if (state->cmd[jump].details.loop.max_iterations >
state->cmd[jump].details.loop.curr_iteration)
{
// jump back to the start
- state->i = jump -1;
+ state->i = jump;
}else{
// Reset the loop counter and continue running
- state->cmd[jump].details.loop.curr_iteration = -1;
+ state->cmd[jump].details.loop.curr_iteration = 0;
}
// Cleaning up the memory in the loop
int j;
@@ -216,8 +215,11 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
case PERF_TALER_MINTDB_CMD_END:
return GNUNET_YES;
+ case PERF_TALER_MINTDB_CMD_DEBUG:
+ printf("%s\n", state->cmd[state->i].label);
+ break;
+
case PERF_TALER_MINTDB_CMD_LOOP:
- state->cmd[state->i].details.loop.curr_iteration++;
break;
case PERF_TALER_MINTDB_CMD_END_LOOP:
diff --git a/src/mintdb/perf_taler_mintdb_interpreter.h b/src/mintdb/perf_taler_mintdb_interpreter.h
index 9556095c5..a10d29d5b 100644
--- a/src/mintdb/perf_taler_mintdb_interpreter.h
+++ b/src/mintdb/perf_taler_mintdb_interpreter.h
@@ -36,6 +36,16 @@
.exposed_type = PERF_TALER_MINTDB_NONE \
}
+
+/**
+ *
+ */
+#define PERF_TALER_MINTDB_INIT_CMD_DEBUG(_label) \
+{ \
+ .command = PERF_TALER_MINTDB_CMD_DEBUG, \
+ .label = _label, \
+ .exposed_type = PERF_TALER_MINTDB_NONE \
+}
/**
* The begining of a loop
* @param _label the name of the loop
@@ -48,7 +58,7 @@
.exposed_type = PERF_TALER_MINTDB_NONE , \
.details.loop = { \
.max_iterations = _iter , \
- .curr_iteration = -1} \
+ .curr_iteration = 0} \
}
/**
@@ -155,6 +165,7 @@
{ \
.command = PERF_TALER_MINTDB_CMD_LOAD_ARRAY, \
.label = _label, \
+ .exposed_type = PERF_TALER_MINTDB_NONE, \
.details.load_array = { \
.label_loop = _label_loop, \
.label_save = _label_save \
@@ -170,8 +181,8 @@
enum PERF_TALER_MINTDB_Type
{
PERF_TALER_MINTDB_NONE,
- PERF_TALER_MINTDB_DEPOSIT,
PERF_TALER_MINTDB_TIME,
+ PERF_TALER_MINTDB_DEPOSIT,
};
@@ -192,7 +203,8 @@ enum PERF_TALER_MINTDB_CMD_Name
{
// All comand chain must hace this as their last command
PERF_TALER_MINTDB_CMD_END,
-
+ // Prints it's label
+ PERF_TALER_MINTDB_CMD_DEBUG,
// Define the start of al command chain loop
PERF_TALER_MINTDB_CMD_LOOP,
//