Skip to content

mimepost: allocate struct on-demand#20260

Closed
bagder wants to merge 1 commit intomasterfrom
bagder/mime-on-demand
Closed

mimepost: allocate struct on-demand#20260
bagder wants to merge 1 commit intomasterfrom
bagder/mime-on-demand

Conversation

@bagder
Copy link
Member

@bagder bagder commented Jan 12, 2026

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.

@bagder bagder marked this pull request as ready for review January 12, 2026 09:03
@bagder bagder changed the title mimepost: allocate main struct on-demand mimepost: allocate struct on-demand Jan 12, 2026
@github-actions github-actions bot added the tests label Jan 12, 2026
@bagder
Copy link
Member Author

bagder commented Jan 12, 2026

augment review

@augmentcode
Copy link

augmentcode bot commented Jan 12, 2026

🤖 Augment PR Summary

Summary: Shrinks the per-easy-handle footprint by making the MIME post container optional instead of always embedded.

Changes:

  • Replaces embedded curl_mimepart mimepost with curl_mimepart *mimepostp in struct UserDefined.
  • Allocates/duplicates/frees the MIME-post part only when needed (setopt/duphandle/cleanup paths).
  • Updates HTTP/SMTP/IMAP code paths to use the new pointer when configuring upload readers and preparing MIME headers.
  • Adjusts the unit struct-size guard (unit3214) to the new expected Curl_easy size.

Technical Notes: Call sites must now handle mimepostp == NULL as “no MIME post configured”.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request optimizes memory usage in the curl easy handle by converting the mimepost field from an embedded struct to an on-demand allocated pointer. This reduces the size of the easy handle by approximately 432-480 bytes by only allocating the 440-byte mimepost struct when MIME POST functionality is actually used.

Changes:

  • Changed mimepost from an embedded curl_mimepart struct to a pointer mimepostp in struct UserDefined
  • Updated the IS_MIME_POST macro to check pointer presence instead of the kind field
  • Modified initialization, cleanup, duplication, and usage code across multiple files to handle the pointer-based approach

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/urldata.h Changed mimepost from embedded struct to pointer mimepostp, updated IS_MIME_POST macro
lib/url.c Removed initialization of embedded struct, updated cleanup to handle pointer
lib/setopt.c Extracted mime post setup into setopt_mimepost function with on-demand allocation
lib/easy.c Updated duplication logic to allocate and copy mimepost pointer on-demand
lib/http.c Updated to use pointer instead of taking address of embedded struct
lib/smtp.c Updated to use pointer and IS_MIME_POST macro for consistency
lib/imap.c Updated to use pointer and IS_MIME_POST macro for consistency
tests/unit/unit3214.c Updated maximum allowed size for CURL_EASY handle (5850 → 5370 bytes)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bagder bagder force-pushed the bagder/mime-on-demand branch from f558cd4 to 669aa0e Compare January 12, 2026 12:53
This makes the easy handle 432 bytes smaller (totally 5184 bytes on my
rather maximized Linux 64 bit build). The 440 byte mimepost struct is
now allocated only when needed.
@bagder bagder force-pushed the bagder/mime-on-demand branch from 669aa0e to e37db14 Compare January 12, 2026 13:34
@bagder bagder closed this in 44312b4 Jan 12, 2026
@bagder bagder deleted the bagder/mime-on-demand branch January 12, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants