fixing memory leak, comments, renaming callback type to make it more concise

This commit is contained in:
Christian Grothoff 2020-03-03 16:35:20 +01:00
parent 9abee82d3c
commit 97fb6b0091
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
5 changed files with 57 additions and 57 deletions

View File

@ -50,7 +50,7 @@ struct TALER_BANK_AdminAddIncomingHandle
/** /**
* Function to call with the result. * Function to call with the result.
*/ */
TALER_BANK_AdminAddIncomingResultCallback cb; TALER_BANK_AdminAddIncomingCallback cb;
/** /**
* Closure for @a cb. * Closure for @a cb.
@ -119,14 +119,13 @@ handle_admin_add_incoming_finished (void *cls,
ec = TALER_JSON_get_error_code (j); ec = TALER_JSON_get_error_code (j);
break; break;
case MHD_HTTP_UNAUTHORIZED: case MHD_HTTP_UNAUTHORIZED:
/* Nothing really to verify, bank says one of the signatures is /* Nothing really to verify, bank says the password is invalid; we should
invalid; as we checked them, this should never happen, we pass the JSON reply to the application */
should pass the JSON reply to the application */
ec = TALER_JSON_get_error_code (j); ec = TALER_JSON_get_error_code (j);
break; break;
case MHD_HTTP_NOT_FOUND: case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never /* Nothing really to verify, maybe account really does not exist.
happen, we should pass the JSON reply to the application */ We should pass the JSON reply to the application */
ec = TALER_JSON_get_error_code (j); ec = TALER_JSON_get_error_code (j);
break; break;
case MHD_HTTP_INTERNAL_SERVER_ERROR: case MHD_HTTP_INTERNAL_SERVER_ERROR:
@ -155,20 +154,20 @@ handle_admin_add_incoming_finished (void *cls,
/** /**
* Notify the bank that we have received an incoming transaction * Perform a wire transfer from some account to the exchange to fill a
* which fills a reserve. Note that this API is an administrative * reserve. Note that this API is usually only used for testing (with
* API and thus not accessible to typical bank clients, but only * fakebank and our Python bank) and thus may not be accessible in a
* to the operators of the bank. * production setting.
* *
* @param ctx curl context for the event loop * @param ctx curl context for the event loop
* @param auth authentication data to send to the bank * @param auth authentication data to send to the bank
* @param reserve_pub wire transfer subject for the transfer * @param reserve_pub wire transfer subject for the transfer
* @param amount amount that was deposited * @param amount amount that was is to be deposited
* @param debit_account account to deposit from (payto URI, but used as 'payfrom') * @param debit_account account to deposit from (payto URI, but used as 'payfrom')
* @param res_cb the callback to call when the final result for this request is available * @param res_cb the callback to call when the final result for this request is available
* @param res_cb_cls closure for the above callback * @param res_cb_cls closure for the above callback
* @return NULL * @return NULL
* if the inputs are invalid (i.e. invalid amount). * if the inputs are invalid (i.e. invalid amount) or internal errors.
* In this case, the callback is not called. * In this case, the callback is not called.
*/ */
struct TALER_BANK_AdminAddIncomingHandle * struct TALER_BANK_AdminAddIncomingHandle *
@ -178,7 +177,7 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
TALER_ReservePublicKeyP *reserve_pub, TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *amount, const struct TALER_Amount *amount,
const char *debit_account, const char *debit_account,
TALER_BANK_AdminAddIncomingResultCallback res_cb, TALER_BANK_AdminAddIncomingCallback res_cb,
void *res_cb_cls) void *res_cb_cls)
{ {
struct TALER_BANK_AdminAddIncomingHandle *aai; struct TALER_BANK_AdminAddIncomingHandle *aai;
@ -206,6 +205,7 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
if (NULL == aai->request_url) if (NULL == aai->request_url)
{ {
GNUNET_free (aai); GNUNET_free (aai);
json_decref (admin_obj);
GNUNET_break (0); GNUNET_break (0);
return NULL; return NULL;
} }

View File

@ -53,7 +53,7 @@ struct TALER_BANK_CreditHistoryHandle
/** /**
* Function to call with the result. * Function to call with the result.
*/ */
TALER_BANK_CreditResultCallback hcb; TALER_BANK_CreditHistoryCallback hcb;
/** /**
* Closure for @a cb. * Closure for @a cb.
@ -233,7 +233,7 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx,
const struct TALER_BANK_AuthenticationData *auth, const struct TALER_BANK_AuthenticationData *auth,
uint64_t start_row, uint64_t start_row,
int64_t num_results, int64_t num_results,
TALER_BANK_CreditResultCallback hres_cb, TALER_BANK_CreditHistoryCallback hres_cb,
void *hres_cb_cls) void *hres_cb_cls)
{ {
char *url; char *url;

View File

@ -48,7 +48,7 @@ struct TALER_BANK_DebitHistoryHandle
/** /**
* Function to call with the result. * Function to call with the result.
*/ */
TALER_BANK_DebitResultCallback hcb; TALER_BANK_DebitHistoryCallback hcb;
/** /**
* Closure for @a cb. * Closure for @a cb.
@ -232,7 +232,7 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
const struct TALER_BANK_AuthenticationData *auth, const struct TALER_BANK_AuthenticationData *auth,
uint64_t start_row, uint64_t start_row,
int64_t num_results, int64_t num_results,
TALER_BANK_DebitResultCallback hres_cb, TALER_BANK_DebitHistoryCallback hres_cb,
void *hres_cb_cls) void *hres_cb_cls)
{ {
char *url; char *url;

View File

@ -123,7 +123,7 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
/** /**
* Free memory inside of @a auth (but not auth itself). * Free memory inside of @a auth (but not @a auth itself).
* Dual to #TALER_BANK_auth_parse_cfg(). * Dual to #TALER_BANK_auth_parse_cfg().
* *
* @param[in] auth authentication data to free * @param[in] auth authentication data to free

View File

@ -90,18 +90,18 @@ struct TALER_BANK_AuthenticationData
}; };
/* ********************* /admin/add/incoming *********************** */ /* ********************* /admin/add-incoming *********************** */
/** /**
* @brief A /admin/add/incoming Handle * @brief A /admin/add-incoming Handle
*/ */
struct TALER_BANK_AdminAddIncomingHandle; struct TALER_BANK_AdminAddIncomingHandle;
/** /**
* Callbacks of this type are used to serve the result of submitting * Callbacks of this type are used to return the result of submitting
* information about an incoming transaction to a bank. * a request to transfer funds to the exchange.
* *
* @param cls closure * @param cls closure
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
@ -112,30 +112,29 @@ struct TALER_BANK_AdminAddIncomingHandle;
* @param json detailed response from the HTTPD, or NULL if reply was not in JSON * @param json detailed response from the HTTPD, or NULL if reply was not in JSON
*/ */
typedef void typedef void
(*TALER_BANK_AdminAddIncomingResultCallback) (void *cls, (*TALER_BANK_AdminAddIncomingCallback) (void *cls,
unsigned int http_status, unsigned int http_status,
enum TALER_ErrorCode ec, enum TALER_ErrorCode ec,
uint64_t serial_id, uint64_t serial_id,
struct GNUNET_TIME_Absolute struct GNUNET_TIME_Absolute timestamp,
timestamp, const json_t *json);
const json_t *json);
/** /**
* Notify the bank that we have received an incoming transaction * Perform a wire transfer from some account to the exchange to fill a
* which fills a reserve. Note that this API is an administrative * reserve. Note that this API is usually only used for testing (with
* API and thus not accessible to typical bank clients, but only * fakebank and our Python bank) and thus may not be accessible in a
* to the operators of the bank. * production setting.
* *
* @param ctx curl context for the event loop * @param ctx curl context for the event loop
* @param auth authentication data to send to the bank * @param auth authentication data to send to the bank
* @param reserve_pub wire transfer subject for the transfer * @param reserve_pub wire transfer subject for the transfer
* @param amount amount that was deposited * @param amount amount that is to be deposited
* @param debit_account account to deposit from (payto URI, but used as 'payfrom') * @param debit_account account to deposit from (payto URI, but used as 'payfrom')
* @param res_cb the callback to call when the final result for this request is available * @param res_cb the callback to call when the final result for this request is available
* @param res_cb_cls closure for the above callback * @param res_cb_cls closure for the above callback
* @return NULL * @return NULL
* if the inputs are invalid (i.e. invalid amount). * if the inputs are invalid (i.e. invalid amount) or internal errors.
* In this case, the callback is not called. * In this case, the callback is not called.
*/ */
struct TALER_BANK_AdminAddIncomingHandle * struct TALER_BANK_AdminAddIncomingHandle *
@ -145,13 +144,13 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
TALER_ReservePublicKeyP *reserve_pub, TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *amount, const struct TALER_Amount *amount,
const char *debit_account, const char *debit_account,
TALER_BANK_AdminAddIncomingResultCallback res_cb, TALER_BANK_AdminAddIncomingCallback res_cb,
void *res_cb_cls); void *res_cb_cls);
/** /**
* Cancel an add incoming. This function cannot be used on a request * Cancel an add incoming operation. This function cannot be used on a
* handle if a response is already served for it. * request handle if a response is already served for it.
* *
* @param aai the admin add incoming request handle * @param aai the admin add incoming request handle
*/ */
@ -163,7 +162,8 @@ TALER_BANK_admin_add_incoming_cancel (struct
/* ********************* /transfer *********************** */ /* ********************* /transfer *********************** */
/** /**
* Prepare for exeuction of a wire transfer. * Prepare for execution of a wire transfer from the exchange to some
* merchant.
* *
* @param destination_account_payto_uri payto:// URL identifying where to send the money * @param destination_account_payto_uri payto:// URL identifying where to send the money
* @param amount amount to transfer, already rounded * @param amount amount to transfer, already rounded
@ -207,7 +207,7 @@ typedef void
/** /**
* Execute a wire transfer. * Execute a wire transfer from the exchange to some merchant.
* *
* @param ctx context for HTTP interaction * @param ctx context for HTTP interaction
* @param auth authentication data to authenticate with the bank * @param auth authentication data to authenticate with the bank
@ -303,13 +303,13 @@ struct TALER_BANK_CreditDetails
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
*/ */
typedef int typedef int
(*TALER_BANK_CreditResultCallback) (void *cls, (*TALER_BANK_CreditHistoryCallback) (void *cls,
unsigned int http_status, unsigned int http_status,
enum TALER_ErrorCode ec, enum TALER_ErrorCode ec,
uint64_t serial_id, uint64_t serial_id,
const struct const struct
TALER_BANK_CreditDetails *details, TALER_BANK_CreditDetails *details,
const json_t *json); const json_t *json);
/** /**
@ -332,7 +332,7 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx,
const struct TALER_BANK_AuthenticationData *auth, const struct TALER_BANK_AuthenticationData *auth,
uint64_t start_row, uint64_t start_row,
int64_t num_results, int64_t num_results,
TALER_BANK_CreditResultCallback hres_cb, TALER_BANK_CreditHistoryCallback hres_cb,
void *hres_cb_cls); void *hres_cb_cls);
@ -413,13 +413,13 @@ struct TALER_BANK_DebitDetails
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
*/ */
typedef int typedef int
(*TALER_BANK_DebitResultCallback) (void *cls, (*TALER_BANK_DebitHistoryCallback) (void *cls,
unsigned int http_status, unsigned int http_status,
enum TALER_ErrorCode ec, enum TALER_ErrorCode ec,
uint64_t serial_id, uint64_t serial_id,
const struct const struct
TALER_BANK_DebitDetails *details, TALER_BANK_DebitDetails *details,
const json_t *json); const json_t *json);
/** /**
@ -442,7 +442,7 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
const struct TALER_BANK_AuthenticationData *auth, const struct TALER_BANK_AuthenticationData *auth,
uint64_t start_row, uint64_t start_row,
int64_t num_results, int64_t num_results,
TALER_BANK_DebitResultCallback hres_cb, TALER_BANK_DebitHistoryCallback hres_cb,
void *hres_cb_cls); void *hres_cb_cls);
@ -476,7 +476,7 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
/** /**
* Free memory inside of @a auth (but not auth itself). * Free memory inside of @a auth (but not @a auth itself).
* Dual to #TALER_BANK_auth_parse_cfg(). * Dual to #TALER_BANK_auth_parse_cfg().
* *
* @param auth authentication data to free * @param auth authentication data to free