curl_share_cleanup(3)

πŸ’… curl_share_cleanup(3) β€” the libcurl manual, but make it make sense πŸŽ€

okay bestie, welcome to the Library Functions Manual for curl_share_cleanup β€” the page that tells you how to say bye-bye to a shared object, and she is short but she is important. ✨


🌸 NAME 🌸

curl_share_cleanup β€” close a shared object. that's it, that's the job. lowkey iconic for being that direct. 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <curl/curl.h>

CURLSHcode curl_share_cleanup(CURLSH *share_handle);

one header, one function, one pointer. clean lines, no notes. πŸ’…


⭐ DESCRIPTION ⭐

so this function deletes a shared object. and once you've called it, the share handle is done β€” cannot be used anymore, periodt. that handle has left the chat. 😭

if you pass in a NULL pointer in share_handle, this function just returns immediately with no action at all. no drama, no crash, just vibes. 🧚

and ngl, this is the important one: any use of the share_handle after this function has been called and has returned is illegal. like, illegal illegal. do not touch, do not reference, do not even look at it. πŸ’€

🌈 PROTOCOLS 🌈

this functionality affects all supported protocols β€” every single one, no cap. πŸ‘‘


πŸŽ€ EXAMPLE πŸŽ€

this is literally the whole lifecycle right here, look at her:

int main(void)
{
  CURLSHcode sh;
  CURLSH *share = curl_share_init();
  sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
  /* use the share, then ... */
  curl_share_cleanup(share);
}

init, setopt, use, cleanup. the main character arc. πŸ’–


πŸ’œ AVAILABILITY πŸ’œ

added in curl 7.10 β€” she's been around a while, a true veteran. ⭐


πŸ”₯ RETURN VALUE πŸ”₯

CURLSHE_OK (zero) means that the option was set properly. non-zero means an error occurred, as <curl/curl.h> defines. for the full list with descriptions, go check out the libcurl-errors(3) man page β€” it's giving encyclopedia but make it useful. πŸ“š

heads up: if an error occurs, then the share object is not deleted. so yeah, she stays. πŸ™ˆ

πŸ“ SEE ALSO πŸ“

the whole friend group, fr fr. 🫢


okay that's the page!! ✨ this was libcurl, dated 2026-10-12, and this specific slice of documentation is curl_share_cleanup(3). now go forth and clean up your shares responsibly, bestie β€” mwah πŸ’‹πŸ’…

πŸ“¦ where this page comes from