remove dead field, avoid unnecessary heap allocation

This commit is contained in:
Christian Grothoff 2020-03-03 19:06:11 +01:00
parent a9b3c564bd
commit 0d30e53585
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 17 additions and 20 deletions

View File

@ -112,6 +112,7 @@ handle_admin_add_incoming_finished (void *cls,
case MHD_HTTP_BAD_REQUEST: case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the bank is buggy /* This should never happen, either us or the bank is buggy
(or API version conflict); just pass JSON reply to the application */ (or API version conflict); just pass JSON reply to the application */
GNUNET_break_op (0);
ec = TALER_JSON_get_error_code (j); ec = TALER_JSON_get_error_code (j);
break; break;
case MHD_HTTP_FORBIDDEN: case MHD_HTTP_FORBIDDEN:

View File

@ -40,11 +40,6 @@ struct TALER_BANK_CreditHistoryHandle
*/ */
char *request_url; char *request_url;
/**
* The base URL of the bank.
*/
char *bank_base_url;
/** /**
* Handle for the request. * Handle for the request.
*/ */
@ -144,8 +139,8 @@ handle_credit_history_finished (void *cls,
const void *response) const void *response)
{ {
struct TALER_BANK_CreditHistoryHandle *hh = cls; struct TALER_BANK_CreditHistoryHandle *hh = cls;
enum TALER_ErrorCode ec;
const json_t *j = response; const json_t *j = response;
enum TALER_ErrorCode ec;
hh->job = NULL; hh->job = NULL;
switch (response_code) switch (response_code)
@ -236,7 +231,7 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx,
TALER_BANK_CreditHistoryCallback hres_cb, TALER_BANK_CreditHistoryCallback hres_cb,
void *hres_cb_cls) void *hres_cb_cls)
{ {
char *url; char url[128];
struct TALER_BANK_CreditHistoryHandle *hh; struct TALER_BANK_CreditHistoryHandle *hh;
CURL *eh; CURL *eh;
@ -250,28 +245,28 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx,
(0 > num_results) ) || (0 > num_results) ) ||
( (0 == start_row) && ( (0 == start_row) &&
(0 < num_results) ) ) (0 < num_results) ) )
GNUNET_asprintf (&url, GNUNET_snprintf (url,
sizeof (url),
"history/incoming?delta=%lld", "history/incoming?delta=%lld",
(long long) num_results); (long long) num_results);
else else
GNUNET_asprintf (&url, GNUNET_snprintf (url,
sizeof (url),
"history/incoming?delta=%lld&start=%llu", "history/incoming?delta=%lld&start=%llu",
(long long) num_results, (long long) num_results,
start_row); (unsigned long long) start_row);
hh = GNUNET_new (struct TALER_BANK_CreditHistoryHandle); hh = GNUNET_new (struct TALER_BANK_CreditHistoryHandle);
hh->hcb = hres_cb; hh->hcb = hres_cb;
hh->hcb_cls = hres_cb_cls; hh->hcb_cls = hres_cb_cls;
hh->request_url = TALER_url_join (auth->wire_gateway_url, hh->request_url = TALER_url_join (auth->wire_gateway_url,
url, url,
NULL); NULL);
GNUNET_free (url);
if (NULL == hh->request_url) if (NULL == hh->request_url)
{ {
GNUNET_free (hh); GNUNET_free (hh);
GNUNET_break (0); GNUNET_break (0);
return NULL; return NULL;
} }
hh->bank_base_url = GNUNET_strdup (auth->wire_gateway_url);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Requesting credit history at `%s'\n", "Requesting credit history at `%s'\n",
hh->request_url); hh->request_url);
@ -316,7 +311,6 @@ TALER_BANK_credit_history_cancel (struct TALER_BANK_CreditHistoryHandle *hh)
hh->job = NULL; hh->job = NULL;
} }
GNUNET_free (hh->request_url); GNUNET_free (hh->request_url);
GNUNET_free (hh->bank_base_url);
GNUNET_free (hh); GNUNET_free (hh);
} }

View File

@ -141,8 +141,8 @@ handle_debit_history_finished (void *cls,
const void *response) const void *response)
{ {
struct TALER_BANK_DebitHistoryHandle *hh = cls; struct TALER_BANK_DebitHistoryHandle *hh = cls;
enum TALER_ErrorCode ec;
const json_t *j = response; const json_t *j = response;
enum TALER_ErrorCode ec;
hh->job = NULL; hh->job = NULL;
switch (response_code) switch (response_code)
@ -235,7 +235,7 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
TALER_BANK_DebitHistoryCallback hres_cb, TALER_BANK_DebitHistoryCallback hres_cb,
void *hres_cb_cls) void *hres_cb_cls)
{ {
char *url; char url[128];
struct TALER_BANK_DebitHistoryHandle *hh; struct TALER_BANK_DebitHistoryHandle *hh;
CURL *eh; CURL *eh;
@ -249,21 +249,22 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
(0 > num_results) ) || (0 > num_results) ) ||
( (0 == start_row) && ( (0 == start_row) &&
(0 < num_results) ) ) (0 < num_results) ) )
GNUNET_asprintf (&url, GNUNET_snprintf (url,
sizeof (url),
"history/outgoing?delta=%lld", "history/outgoing?delta=%lld",
(long long) num_results); (long long) num_results);
else else
GNUNET_asprintf (&url, GNUNET_snprintf (url,
sizeof (url),
"history/outgoing?delta=%lld&start=%llu", "history/outgoing?delta=%lld&start=%llu",
(long long) num_results, (long long) num_results,
start_row); (unsigned long long) start_row);
hh = GNUNET_new (struct TALER_BANK_DebitHistoryHandle); hh = GNUNET_new (struct TALER_BANK_DebitHistoryHandle);
hh->hcb = hres_cb; hh->hcb = hres_cb;
hh->hcb_cls = hres_cb_cls; hh->hcb_cls = hres_cb_cls;
hh->request_url = TALER_url_join (auth->wire_gateway_url, hh->request_url = TALER_url_join (auth->wire_gateway_url,
url, url,
NULL); NULL);
GNUNET_free (url);
if (NULL == hh->request_url) if (NULL == hh->request_url)
{ {
GNUNET_free (hh); GNUNET_free (hh);
@ -271,7 +272,7 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
return NULL; return NULL;
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Requesting history at `%s'\n", "Requesting debit history at `%s'\n",
hh->request_url); hh->request_url);
eh = curl_easy_init (); eh = curl_easy_init ();
if ( (NULL == eh) || if ( (NULL == eh) ||

View File

@ -204,6 +204,7 @@ handle_transfer_finished (void *cls,
case MHD_HTTP_BAD_REQUEST: case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the bank is buggy /* This should never happen, either us or the bank is buggy
(or API version conflict); just pass JSON reply to the application */ (or API version conflict); just pass JSON reply to the application */
GNUNET_break_op (0);
ec = TALER_JSON_get_error_code (j); ec = TALER_JSON_get_error_code (j);
break; break;
case MHD_HTTP_UNAUTHORIZED: case MHD_HTTP_UNAUTHORIZED: