diff options
Diffstat (limited to 'src/reducer/anastasis_api_backup_redux.c')
-rw-r--r-- | src/reducer/anastasis_api_backup_redux.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/reducer/anastasis_api_backup_redux.c b/src/reducer/anastasis_api_backup_redux.c index 27a79c0..e025810 100644 --- a/src/reducer/anastasis_api_backup_redux.c +++ b/src/reducer/anastasis_api_backup_redux.c @@ -835,6 +835,9 @@ eval_provider_selection (struct PolicyBuilder *pb, unsigned int curr_diversity; struct PolicyEntry policy_ent[pb->req_methods]; + memset (policy_ent, + 0, + sizeof (policy_ent)); for (unsigned int i = 0; i < pb->req_methods; i++) { const json_t *method_obj = json_array_get (pb->methods, @@ -869,7 +872,6 @@ eval_provider_selection (struct PolicyBuilder *pb, }; policy_ent[i].provider_name = prov_sel[i]; - policy_ent[i].usage_fee = NULL; if (GNUNET_OK != GNUNET_JSON_parse (method_obj, mspec, @@ -878,6 +880,8 @@ eval_provider_selection (struct PolicyBuilder *pb, GNUNET_break (0); pb->ec = TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID; pb->hint = "'authentication_method' content malformed"; + for (unsigned int i = 0; i<pb->req_methods; i++) + free_costs (policy_ent[i].usage_fee); return; } @@ -886,6 +890,8 @@ eval_provider_selection (struct PolicyBuilder *pb, "http_status"))) { GNUNET_JSON_parse_free (mspec); + for (unsigned int i = 0; i<pb->req_methods; i++) + free_costs (policy_ent[i].usage_fee); return; /* skip providers that are down */ } if (GNUNET_OK != @@ -897,6 +903,8 @@ eval_provider_selection (struct PolicyBuilder *pb, "Skipping provider %s: no suitable configuration\n", prov_sel[i]); GNUNET_JSON_parse_free (mspec); + for (unsigned int i = 0; i<pb->req_methods; i++) + free_costs (policy_ent[i].usage_fee); return; } json_array_foreach (provider_methods, index, md) @@ -920,6 +928,8 @@ eval_provider_selection (struct PolicyBuilder *pb, pb->ec = TALER_EC_ANASTASIS_REDUCER_STATE_INVALID; pb->hint = "'methods' of provider"; GNUNET_JSON_parse_free (pspec); + for (unsigned int i = 0; i<pb->req_methods; i++) + free_costs (policy_ent[i].usage_fee); return; } if ( (0 == strcmp (type, @@ -941,6 +951,8 @@ eval_provider_selection (struct PolicyBuilder *pb, Cost is basically 'infinite', but we simply then skip this. */ GNUNET_JSON_parse_free (pspec); GNUNET_JSON_parse_free (mspec); + for (unsigned int i = 0; i<pb->req_methods; i++) + free_costs (policy_ent[i].usage_fee); return; } GNUNET_JSON_parse_free (mspec); @@ -972,8 +984,12 @@ eval_provider_selection (struct PolicyBuilder *pb, pb->best_diversity); #endif if (curr_diversity < pb->best_diversity) + { + for (unsigned int i = 0; i<pb->req_methods; i++) + free_costs (policy_ent[i].usage_fee); return; /* do not allow combinations that are bad for provider diversity */ + } if (curr_diversity > pb->best_diversity) { /* drop existing policies, they are all worse */ @@ -1016,7 +1032,11 @@ eval_provider_selection (struct PolicyBuilder *pb, } } if (equiv) + { + for (unsigned int i = 0; i<pb->req_methods; i++) + free_costs (policy_ent[i].usage_fee); return; /* equivalent to known allocation */ + } } } |