mirror of
https://github.com/curl/curl.git
synced 2026-04-18 10:01:40 +03:00
ngtcp2: use custom mem funcs
Pass curl's memory functions to the nghttp3 and ngtcp2 functions that allow them. This allows custom memory functions passed by the curl user to be used in nghttp3 and ngtcp2. Closes #18196
This commit is contained in:
parent
fc4ae23cc2
commit
7dafe10db2
4 changed files with 68 additions and 3 deletions
|
|
@ -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_default(),
|
||||
Curl_nghttp3_mem(),
|
||||
cf);
|
||||
if(rc) {
|
||||
failf(data, "error creating nghttp3 connection instance");
|
||||
|
|
@ -2475,7 +2475,7 @@ static const struct alpn_spec ALPN_SPEC_H3 = {
|
|||
&ctx->connected_path,
|
||||
NGTCP2_PROTO_VER_V1, &ng_callbacks,
|
||||
&ctx->settings, &ctx->transport_params,
|
||||
NULL, cf);
|
||||
Curl_ngtcp2_mem(), cf);
|
||||
if(rc)
|
||||
return CURLE_QUIC_CONNECT_ERROR;
|
||||
|
||||
|
|
|
|||
|
|
@ -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_default(),
|
||||
Curl_nghttp3_mem(),
|
||||
user_data);
|
||||
if(rc) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
|
|
|
|||
|
|
@ -724,6 +724,62 @@ CURLcode Curl_conn_may_http3(struct Curl_easy *data,
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
#if defined(USE_NGTCP2) || defined(USE_NGHTTP3)
|
||||
|
||||
static void *Curl_ngtcp2_malloc(size_t size, void *user_data)
|
||||
{
|
||||
(void)user_data;
|
||||
return Curl_cmalloc(size);
|
||||
}
|
||||
|
||||
static void Curl_ngtcp2_free(void *ptr, void *user_data)
|
||||
{
|
||||
(void)user_data;
|
||||
Curl_cfree(ptr);
|
||||
}
|
||||
|
||||
static void *Curl_ngtcp2_calloc(size_t nmemb, size_t size, void *user_data)
|
||||
{
|
||||
(void)user_data;
|
||||
return Curl_ccalloc(nmemb, size);
|
||||
}
|
||||
|
||||
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 struct ngtcp2_mem curl_ngtcp2_mem = {
|
||||
NULL,
|
||||
Curl_ngtcp2_malloc,
|
||||
Curl_ngtcp2_free,
|
||||
Curl_ngtcp2_calloc,
|
||||
Curl_ngtcp2_realloc
|
||||
};
|
||||
struct ngtcp2_mem *Curl_ngtcp2_mem(void)
|
||||
{
|
||||
return &curl_ngtcp2_mem;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_NGHTTP3
|
||||
static struct nghttp3_mem curl_nghttp3_mem = {
|
||||
NULL,
|
||||
Curl_ngtcp2_malloc,
|
||||
Curl_ngtcp2_free,
|
||||
Curl_ngtcp2_calloc,
|
||||
Curl_ngtcp2_realloc
|
||||
};
|
||||
struct nghttp3_mem *Curl_nghttp3_mem(void)
|
||||
{
|
||||
return &curl_nghttp3_mem;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* USE_NGTCP2 || USE_NGHTTP3 */
|
||||
|
||||
#else /* CURL_DISABLE_HTTP || !USE_HTTP3 */
|
||||
|
||||
CURLcode Curl_conn_may_http3(struct Curl_easy *data,
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue