remove casts, static funcs

This commit is contained in:
David Zhuang 2025-08-11 19:37:40 -07:00
parent 681bb150a1
commit 6da02431c6
5 changed files with 26 additions and 27 deletions

View file

@ -1212,7 +1212,7 @@ static CURLcode init_ngh3_conn(struct Curl_cfilter *cf,
rc = nghttp3_conn_client_new(&ctx->h3conn,
&ngh3_callbacks,
&ctx->h3settings,
(nghttp3_mem *)Curl_nghttp3_mem(),
Curl_nghttp3_mem(),
cf);
if(rc) {
failf(data, "error creating nghttp3 connection instance");
@ -2471,7 +2471,7 @@ static const struct alpn_spec ALPN_SPEC_H3 = {
&ctx->connected_path,
NGTCP2_PROTO_VER_V1, &ng_callbacks,
&ctx->settings, &ctx->transport_params,
(ngtcp2_mem *)Curl_ngtcp2_mem(), cf);
Curl_ngtcp2_mem(), cf);
if(rc)
return CURLE_QUIC_CONNECT_ERROR;

View file

@ -1106,7 +1106,7 @@ static CURLcode cf_osslq_h3conn_init(struct cf_osslq_ctx *ctx, SSL *conn,
rc = nghttp3_conn_client_new(&h3->conn,
&ngh3_callbacks,
&h3->settings,
(nghttp3_mem *)Curl_nghttp3_mem(),
Curl_nghttp3_mem(),
user_data);
if(rc) {
result = CURLE_OUT_OF_MEMORY;

View file

@ -725,50 +725,56 @@ CURLcode Curl_conn_may_http3(struct Curl_easy *data,
#if defined(USE_NGTCP2) || defined(USE_NGHTTP3)
void *Curl_ngtcp2_malloc(size_t size, void *user_data)
static void *Curl_ngtcp2_malloc(size_t size, void *user_data)
{
(void)user_data;
return Curl_cmalloc(size);
}
void Curl_ngtcp2_free(void *ptr, void *user_data)
static void Curl_ngtcp2_free(void *ptr, void *user_data)
{
(void)user_data;
Curl_cfree(ptr);
}
void *Curl_ngtcp2_calloc(size_t nmemb, size_t size, void *user_data)
static void *Curl_ngtcp2_calloc(size_t nmemb, size_t size, void *user_data)
{
(void)user_data;
return Curl_ccalloc(nmemb, size);
}
void *Curl_ngtcp2_realloc(void *ptr, size_t size, void *user_data)
static void *Curl_ngtcp2_realloc(void *ptr, size_t size, void *user_data)
{
(void)user_data;
return Curl_crealloc(ptr, size);
}
#ifdef USE_NGTCP2
static ngtcp2_mem curl_ngtcp2_mem_ = {
static struct ngtcp2_mem curl_ngtcp2_mem_ = {
NULL,
Curl_ngtcp2_malloc,
Curl_ngtcp2_free,
Curl_ngtcp2_calloc,
Curl_ngtcp2_realloc
};
void *Curl_ngtcp2_mem(void) { return (void *)&curl_ngtcp2_mem_; }
struct ngtcp2_mem *Curl_ngtcp2_mem(void)
{
return &curl_ngtcp2_mem_;
}
#endif
#ifdef USE_NGHTTP3
static nghttp3_mem curl_nghttp3_mem_ = {
static struct nghttp3_mem curl_nghttp3_mem_ = {
NULL,
Curl_ngtcp2_malloc,
Curl_ngtcp2_free,
Curl_ngtcp2_calloc,
Curl_ngtcp2_realloc
};
void *Curl_nghttp3_mem(void) { return (void *)&curl_nghttp3_mem_; }
struct nghttp3_mem *Curl_nghttp3_mem(void)
{
return &curl_nghttp3_mem_;
}
#endif
#endif /* USE_NGTCP2 || USE_NGHTTP3 */

View file

@ -49,22 +49,6 @@ CURLcode Curl_cf_quic_create(struct Curl_cfilter **pcf,
extern struct Curl_cftype Curl_cft_http3;
#if defined(USE_NGTCP2) || defined(USE_NGHTTP3)
void *Curl_ngtcp2_malloc(size_t size, void *user_data);
void Curl_ngtcp2_free(void *ptr, void *user_data);
void *Curl_ngtcp2_calloc(size_t nmemb, size_t size, void *user_data);
void *Curl_ngtcp2_realloc(void *ptr, size_t size, void *user_data);
#ifdef USE_NGTCP2
void *Curl_ngtcp2_mem(void);
#endif
#ifdef USE_NGHTTP3
void *Curl_nghttp3_mem(void);
#endif
#endif /* USE_NGTCP2 || USE_NGHTTP3 */
#else
#define Curl_vquic_init() 1
#endif /* !CURL_DISABLE_HTTP && USE_HTTP3 */

View file

@ -91,4 +91,13 @@ CURLcode vquic_recv_packets(struct Curl_cfilter *cf,
#endif /* !USE_HTTP3 */
#ifdef USE_NGTCP2
struct ngtcp2_mem;
struct ngtcp2_mem *Curl_ngtcp2_mem(void);
#endif
#ifdef USE_NGHTTP3
struct nghttp3_mem;
struct nghttp3_mem *Curl_nghttp3_mem(void);
#endif
#endif /* HEADER_CURL_VQUIC_QUIC_INT_H */