quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

commit e1aa89af968473fdbb8d5b3782a6f83d834be285
parent 1c1b2995f80d0f42e24f5bce231af35e1de4e030
Author: Marc Stibane <marc@taler.net>
Date:   Wed, 28 Feb 2024 13:13:56 +0100

Separate struct creation and usage

Diffstat:
Mtaler_wallet_core_lib.c | 12+++++-------
Mtaler_wallet_core_lib.h | 13++++++-------
Mtaler_wallet_core_lib_preprocessed.h | 13++++++-------
3 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/taler_wallet_core_lib.c b/taler_wallet_core_lib.c @@ -336,17 +336,15 @@ TALER_set_http_client_implementation(struct TALER_WALLET_Instance *twi, } #pragma mark - -void -TALER_set_native_http_client_implementation(struct TALER_WALLET_Instance *twi, - JSHttpReqCreateFn req_create, - JSHttpReqCancelFn req_cancel, - void *handler_p) +struct JSHttpClientImplementation * +TALER_pack_http_client_implementation(JSHttpReqCreateFn req_create, + JSHttpReqCancelFn req_cancel, + void *handler_p) { // will (and should!) crash if this tiny malloc fails struct JSHttpClientImplementation *impl = malloc(sizeof *impl); impl->cls = handler_p; impl->req_create = req_create; impl->req_cancel = req_cancel; - twi->http_impl = impl; - // no need to free impl, because this is a singleton + return impl; } diff --git a/taler_wallet_core_lib.h b/taler_wallet_core_lib.h @@ -165,16 +165,15 @@ TALER_set_http_client_implementation(struct TALER_WALLET_Instance *twi, #pragma mark - /** - * Set the native HTTP client implementation to be used by the wallet. + * Build JSHttpClientImplementation struct for native HTTP client implementation to be used by the wallet. * - * @param twi wallet-core instance * @param req_create HTTP client implementation * @param req_cancel HTTP client implementation + * @param handler_p Pointer to Handler's "this" */ -void -TALER_set_native_http_client_implementation(struct TALER_WALLET_Instance *twi, - JSHttpReqCreateFn req_create, - JSHttpReqCancelFn req_cancel, - void *handler_p); +struct JSHttpClientImplementation * +TALER_pack_http_client_implementation(JSHttpReqCreateFn req_create, + JSHttpReqCancelFn req_cancel, + void *handler_p); #endif /*_TALER_WALLET_LIB_H */ diff --git a/taler_wallet_core_lib_preprocessed.h b/taler_wallet_core_lib_preprocessed.h @@ -374,16 +374,15 @@ TALER_set_http_client_implementation(struct TALER_WALLET_Instance *twi, #pragma mark - /** - * Set the native HTTP client implementation to be used by the wallet. + * Build JSHttpClientImplementation struct for native HTTP client implementation to be used by the wallet. * - * @param twi wallet-core instance * @param req_create HTTP client implementation * @param req_cancel HTTP client implementation + * @param handler_p Pointer to Handler's "this" */ -void -TALER_set_native_http_client_implementation(struct TALER_WALLET_Instance *twi, - JSHttpReqCreateFn req_create, - JSHttpReqCancelFn req_cancel, - void *handler_p); +struct JSHttpClientImplementation * +TALER_pack_http_client_implementation(JSHttpReqCreateFn req_create, + JSHttpReqCancelFn req_cancel, + void *handler_p); #endif /*_TALER_WALLET_LIB_H */