curl_mime_free(3)

πŸ’… curl_mime_free β€” bestie's guide to cleaning up your mime era πŸ’…

okay so this is a page from the Library Functions Manual for curl_mime_free(3), and honestly? it's the "pack up your stuff and go home" of the curl mime world. let's get into it πŸŽ€


✨ NAME ✨

curl_mime_free β€” free a previously built mime structure. that's it, that's the whole vibe. it's the cleanup fairy 🧚


🌸 SYNOPSIS 🌸

#include <curl/curl.h>

void curl_mime_free(curl_mime *mime);

like, look at her. void in, void out. no return value, no drama, no cap πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so curl_mime_free(3) is literally the function you use to clean up data that was previously built/appended with curl_mime_addpart(3) and the other mime-handling functions. think of it as ~closing the tab~ on all that mime content you were out here constructing.

you must call it once the data has been used, and "used" typically means after curl_easy_perform(3) has been called. like, don't leave it hanging, bestie 😭 that's not the move.

the handle to free is the one you passed to the CURLOPT_MIMEPOST(3) option β€” that's the important part. attached sub part mime structures must not be explicitly freed, because they get freed by the top structure doing the freeing. the top structure handles her business and takes care of the little ones too πŸ‘‘ no double-freeing, iykyk.

mime is the handle as returned from a previous call to curl_mime_init(3), and it may be NULL. yes, queen, flexible.

and passing in a NULL pointer in mime makes this function return immediately with no action. literally does nothing, no notes, no error, just vibes πŸ™ˆ


πŸ”₯ PROTOCOLS πŸ”₯

this functionality affects http, imap and smtp β€” a versatile icon in all three eras ⭐


🌈 EXAMPLE 🌈

okay here's the whole thing in action, and it's giving main character energy fr fr:

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    /* Build the mime message. */
    curl_mime *mime = curl_mime_init(curl);

    /* send off the transfer */

    /* Free multipart message. */
    curl_mime_free(mime);
  }
}

see how she builds it, sends it, then frees it? that's the whole lifecycle. beautiful. iconic. no leaks πŸ’œ


πŸ“ AVAILABILITY πŸ“

added in curl 7.56.0 β€” so she's been around, but she's still that girl ✨


πŸ’€ RETURN VALUE πŸ’€

None. nothing. zero. niente. she does her job and leaves without a word 🫢


πŸ‘‘ SEE ALSO πŸ‘‘

(go read those too, they're part of the same friend group πŸ’–)


lowkey a reminder: don't go freeing the sub parts yourself. that's giving chaos and it's not cute. the top structure handles it. periodt πŸ’…

okay that's the page!! sourced straight from libcurl, dated 2026-10-12, and that's the whole curl_mime_free(3) situation β€” go forth and free responsibly, bestie πŸŒΈπŸŽ€βœ¨

πŸ“¦ where this page comes from