curl_easy_cleanup(3)
π curl_easy_cleanup(3) β the libcurl girlies' guide
so this is curl_easy_cleanup from the Library Functions Manual bestie, and it's literally the breakup song of the libcurl discography π
β¨ NAME β¨
curl_easy_cleanup β free an easy handle π¦
β¨ SYNOPSIS β¨
#include <curl/curl.h>
void curl_easy_cleanup(CURL *handle);
β¨ DESCRIPTION β¨
okay so picture this: this function is the literal opposite of curl_easy_init(3). It closes down and frees, like, all the resources that were previously associated with this easy handle. everything. gone. clean slate energy β¨
it closes all connections this handle has used and β this is the spicy part β possibly has kept open until now, unless the easy handle was attached to a multi handle while doing the transfers. π
π¨ bestie do NOT call this function if you intend to transfer more files. reusing handles is a key to good performance with libcurl, i'm not kidding, the way that reusing handles just makes everything faster, iykyk π
occasionally you may get your progress callback or header callback called from within curl_easy_cleanup(3) β yeah, from the inside, messy π β (if previously set for the handle using curl_easy_setopt(3)). like if libcurl decides to shut down the connection and the protocol is of a kind that requires a command/response sequence before disconnect. examples of such protocols are FTP, POP3 and IMAP. so don't be shocked when the callbacks show up to the party uninvited π«Ά
Any use of the easy handle after this function has been called and have returned, is illegal. like not "oops my bad" illegal, fr fr illegal. π
To close an easy handle that has been used with the multi interface, make sure to first call curl_multi_remove_handle(3) to remove it from the multi handle before it is closed. order matters, always has πΈ
Passing in a NULL pointer in handle makes this function return immediately with no action. mmm, a no-op, we love a graceful exit π
β¨ PROTOCOLS β¨
This functionality affects all supported protocols π (yes, all of them, every single one, iconic)
β¨ EXAMPLE β¨
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
result = curl_easy_perform(curl);
if(result)
printf("error: %s\n", curl_easy_strerror(result));
curl_easy_cleanup(curl);
}
}
look at that β init, setopt, perform, error check, cleanup. the whole little lifecycle, so satisfying, it's giving main character energy β
β¨ AVAILABILITY β¨
Added in curl 7.1 π (she's been here a while, a real veteran π)
β¨ RETURN VALUE β¨
None β returns nothing, gives nothing, just vibes and cleanup π§
β¨ SEE ALSO β¨
curl_easy_duphandle(3)curl_easy_init(3)curl_easy_reset(3)curl_multi_cleanup(3)curl_multi_remove_handle(3)
that's the whole page bestie, go free those handles responsibly π«Ά
<div>β from the libcurl girlies, dated 2026-10-12, page curl_easy_cleanup(3), slay β¨π</div>
π¦ 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