curl_formfree(3)
π curl_formfree(3) β free a previously build multipart form post chain
ok so real talk bestie, this is a page from the libcurl Library Functions Manual (yes, that libcurl, the one you've been linking against since forever π«Ά), and it's about tidying up after yourself. Let's get into it.
β¨ SYNOPSIS β¨
#include <curl/curl.h>
void curl_formfree(struct curl_httppost *form);
that's the whole vibe. one include, one function, zero drama π
πΈ DESCRIPTION πΈ
okay so first things first, and I need you to hear me on this one:
This function is deprecated. Do not use. π¨ See curl_mime_init(3) instead. like, genuinely, go look at that one.
curl_formfree() is the little cleanup crew π§Ή for data you previously built/appended with curl_formadd(3). You must call it when the data has been used β and "used" typically means after curl_easy_perform(3) has been called. it's giving "return the shopping cart" energy, ngl.
the pointer you free is the same pointer you passed to the CURLOPT_HTTPPOST(3) option, which is the firstitem pointer from the curl_formadd(3) invoke(s). same one, no copies, iykyk.
form is the pointer as returned from a previous call to curl_formadd(3) and may be NULL.
and if you pass in a NULL pointer in form? the function returns immediately with no action. literally just π and leaves. no crash, no fuss. iconic behaviour honestly.
π PROTOCOLS π
this functionality affects http only. that's the whole list. http girlies only π
π¦ EXAMPLE π¦
here's the whole thing in action, bestie β copy it exactly:
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
struct curl_httppost *formpost;
struct curl_httppost *lastptr;
/* Fill in a file upload field */
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "file",
CURLFORM_FILE, "nice-image.jpg",
CURLFORM_END);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
curl_easy_perform(curl);
/* then cleanup the formpost chain */
curl_formfree(formpost);
}
}
see how formpost goes into curl_formadd, then into CURLOPT_HTTPPOST, then finally into curl_formfree? that's the full circle moment π₯ main character energy from start to finish.
π DEPRECATED π
Deprecated in 7.56.0. so yeah. it's a legacy era. respect the history, but move on π
β AVAILABILITY β
Added in curl 7.1. ancient. vintage. a true elder of the library π
π RETURN VALUE π
None. that's it. nothing comes back. empty handed but at peace π§
π SEE ALSO π
k that's the page!! stay safe, free your formposts, and please please please use the curl_mime_* family instead π
β with love, from the libcurl manual, dated 2026-10-12 π¦β¨
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms