CURLSHOPT_USERDATA(3)
π CURLSHOPT_USERDATA(3) π
okay so bestie, welcome to the libcurl Library Functions Manual page for CURLSHOPT_USERDATA β and yes this is exactly as niche and iconic as it sounds π
β¨ NAME β¨
CURLSHOPT_USERDATA β the pointer that gets passed to the lock and unlock mutex callbacks π«Ά
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_USERDATA, void *clientp);
π¦ DESCRIPTION π¦
So here's the tea, bestie: libcurl holds onto that clientp parameter verbatim β like, it does not copy it, does not peek inside, does not judge it, nothing. It just holds it. π
And then it passes that same thing on as the clientp argument to the callbacks you set up with CURLSHOPT_LOCKFUNC(3) and CURLSHOPT_UNLOCKFUNC(3). That's it. That's the whole job. Hand it a pointer, it hands it back to your callbacks. Simple, clean, slay. β¨
π PROTOCOLS π
This functionality affects all supported protocols π (all of them, no cap)
π EXAMPLE π
struct secrets {
void *custom;
};
int main(void)
{
CURLSHcode sh;
struct secrets private_stuff;
CURLSH *share = curl_share_init();
sh = curl_share_setopt(share, CURLSHOPT_USERDATA, &private_stuff);
if(sh)
printf("Error: %s\n", curl_share_strerror(sh));
}
look at her go π she's passing &private_stuff in and letting libcurl hold it. main character pointer energy fr fr.
β AVAILABILITY β
Added in curl 7.10.3 β retro icon behavior, honestly π
π RETURN VALUE π
CURLSHE_OK (zero) means that the option was set properly π β non-zero means an error occurred π. See libcurl-errors(3) for the full list with descriptions, iykyk.
π§ SEE ALSO π§
π
reminder bestie: libcurl holds your clientp verbatim β it does not copy it. So keep that memory alive for as long as your callbacks might need it. No dangling pointers on my watch π«Ά
mwah, that's a wrap π brought to you by libcurl, dated 2026-10-12, from the CURLSHOPT_USERDATA(3) page β go forth and share responsibly, queen πβ¨
π¦ 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