mimepost: allocate main struct on-demand

This makes the easy handle 432 bytes smaller (totally 5352 bytes on my
rather maximized Linux 64 bit build). The 440 byte mimepost struct is
now allocated only when needed.

Closes #20260
This commit is contained in:
Daniel Stenberg 2026-01-12 09:30:25 +01:00
parent 9e0b02c19c
commit 44312b4b11
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
9 changed files with 79 additions and 45 deletions

View file

@ -27,6 +27,8 @@ static CURLcode test_lib589(const char *URL)
{
CURL *curl;
CURLcode result = CURLE_OK;
curl_mime *mime = NULL;
curl_mimepart *part;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
curl_mfprintf(stderr, "curl_global_init() failed\n");
@ -46,13 +48,14 @@ static CURLcode test_lib589(const char *URL)
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
if(testnum == 584) {
curl_mime *mime = curl_mime_init(curl);
curl_mimepart *part = curl_mime_addpart(mime);
curl_mime_name(part, "fake");
curl_mime_data(part, "party", 5);
test_setopt(curl, CURLOPT_MIMEPOST, mime);
result = curl_easy_perform(curl);
curl_mime_free(mime);
mime = curl_mime_init(curl);
part = curl_mime_addpart(mime);
if(mime && part) {
curl_mime_name(part, "fake");
curl_mime_data(part, "party", 5);
test_setopt(curl, CURLOPT_MIMEPOST, mime);
result = curl_easy_perform(curl);
}
if(result)
goto test_cleanup;
}
@ -65,6 +68,7 @@ static CURLcode test_lib589(const char *URL)
test_cleanup:
/* always cleanup */
curl_mime_free(mime);
curl_easy_cleanup(curl);
curl_global_cleanup();

View file

@ -41,7 +41,7 @@ static void checksize(const char *name, size_t size, size_t allowed)
}
/* the maximum sizes we allow specific structs to grow to */
#define MAX_CURL_EASY 5850
#define MAX_CURL_EASY 5370
#define MAX_CONNECTDATA 1300
#define MAX_CURL_MULTI 850
#define MAX_CURL_HTTPPOST 112