static struct

This commit is contained in:
David Zhuang 2025-08-08 16:54:16 -07:00
parent 8487281b52
commit 681bb150a1
4 changed files with 33 additions and 9 deletions

View file

@ -1199,8 +1199,6 @@ static CURLcode init_ngh3_conn(struct Curl_cfilter *cf,
struct Curl_easy *data)
{
struct cf_ngtcp2_ctx *ctx = cf->ctx;
nghttp3_mem mem = {NULL, Curl_ngtcp2_malloc, Curl_ngtcp2_free,
Curl_ngtcp2_calloc, Curl_ngtcp2_realloc};
int64_t ctrl_stream_id, qpack_enc_stream_id, qpack_dec_stream_id;
int rc;
@ -1214,7 +1212,8 @@ static CURLcode init_ngh3_conn(struct Curl_cfilter *cf,
rc = nghttp3_conn_client_new(&ctx->h3conn,
&ngh3_callbacks,
&ctx->h3settings,
&mem, cf);
(nghttp3_mem *)Curl_nghttp3_mem(),
cf);
if(rc) {
failf(data, "error creating nghttp3 connection instance");
return CURLE_OUT_OF_MEMORY;
@ -2425,8 +2424,6 @@ static CURLcode cf_connect_start(struct Curl_cfilter *cf,
struct pkt_io_ctx *pktx)
{
struct cf_ngtcp2_ctx *ctx = cf->ctx;
ngtcp2_mem mem = {NULL, Curl_ngtcp2_malloc, Curl_ngtcp2_free,
Curl_ngtcp2_calloc, Curl_ngtcp2_realloc};
int rc;
int rv;
CURLcode result;
@ -2474,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,
&mem, cf);
(ngtcp2_mem *)Curl_ngtcp2_mem(), cf);
if(rc)
return CURLE_QUIC_CONNECT_ERROR;

View file

@ -1099,8 +1099,6 @@ static CURLcode cf_osslq_h3conn_init(struct cf_osslq_ctx *ctx, SSL *conn,
void *user_data)
{
struct cf_osslq_h3conn *h3 = &ctx->h3;
nghttp3_mem mem = {NULL, Curl_ngtcp2_malloc, Curl_ngtcp2_free,
Curl_ngtcp2_calloc, Curl_ngtcp2_realloc};
CURLcode result;
int rc;
@ -1108,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,
&mem,
(nghttp3_mem *)Curl_nghttp3_mem(),
user_data);
if(rc) {
result = CURLE_OUT_OF_MEMORY;

View file

@ -749,6 +749,28 @@ void *Curl_ngtcp2_realloc(void *ptr, size_t size, void *user_data)
return Curl_crealloc(ptr, size);
}
#ifdef USE_NGTCP2
static 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_; }
#endif
#ifdef USE_NGHTTP3
static 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_; }
#endif
#endif /* USE_NGTCP2 || USE_NGHTTP3 */
#else /* CURL_DISABLE_HTTP || !USE_HTTP3 */

View file

@ -56,6 +56,13 @@ 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