ftp: allocate the wildcard struct on demand

The feature is rarely used so this frees up data for the vast majority
of easy handles that don't use it.

Rename "protdata" to "ftpwc" since it is always an FTP wildcard struct
pointer. Made the state struct field an unsigned char to save space.

Closes #10639
This commit is contained in:
Daniel Stenberg 2023-02-27 23:57:23 +01:00
parent c84c0f9aa3
commit 9c188e771c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
7 changed files with 33 additions and 24 deletions

View file

@ -1402,7 +1402,13 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
#ifndef CURL_DISABLE_FTP
data->state.wildcardmatch = data->set.wildcard_enabled;
if(data->state.wildcardmatch) {
struct WildcardData *wc = &data->wildcard;
struct WildcardData *wc;
if(!data->wildcard) {
data->wildcard = calloc(1, sizeof(struct WildcardData));
if(!data->wildcard)
return CURLE_OUT_OF_MEMORY;
}
wc = data->wildcard;
if(wc->state < CURLWC_INIT) {
result = Curl_wildcard_init(wc); /* init wildcard structures */
if(result)