content_encoding: support use of custom libzstd memory functions
If ZSTD_STATIC_LINKING_ONLY is defined. This functionality was introduced in zstd v0.8.1 in 2016 here: facebook/zstd@be6180c Closes #16028
This commit is contained in:
parent
5fd7bd4379
commit
c80715169c
@ -742,6 +742,20 @@ struct zstd_writer {
|
|||||||
void *decomp;
|
void *decomp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef ZSTD_STATIC_LINKING_ONLY
|
||||||
|
static void *Curl_zstd_alloc(void *opaque, size_t size)
|
||||||
|
{
|
||||||
|
(void)opaque;
|
||||||
|
return Curl_cmalloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Curl_zstd_free(void *opaque, void *address)
|
||||||
|
{
|
||||||
|
(void)opaque;
|
||||||
|
Curl_cfree(address);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static CURLcode zstd_do_init(struct Curl_easy *data,
|
static CURLcode zstd_do_init(struct Curl_easy *data,
|
||||||
struct Curl_cwriter *writer)
|
struct Curl_cwriter *writer)
|
||||||
{
|
{
|
||||||
@ -749,7 +763,16 @@ static CURLcode zstd_do_init(struct Curl_easy *data,
|
|||||||
|
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
|
#ifdef ZSTD_STATIC_LINKING_ONLY
|
||||||
|
zp->zds = ZSTD_createDStream_advanced((ZSTD_customMem) {
|
||||||
|
.customAlloc = Curl_zstd_alloc,
|
||||||
|
.customFree = Curl_zstd_free,
|
||||||
|
.opaque = NULL
|
||||||
|
});
|
||||||
|
#else
|
||||||
zp->zds = ZSTD_createDStream();
|
zp->zds = ZSTD_createDStream();
|
||||||
|
#endif
|
||||||
|
|
||||||
zp->decomp = NULL;
|
zp->decomp = NULL;
|
||||||
return zp->zds ? CURLE_OK : CURLE_OUT_OF_MEMORY;
|
return zp->zds ? CURLE_OK : CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user