curl_url_dup(3)
β¨ curl_url_dup(3) β¨
okay so bestie, welcome to the curl_url_dup page β it lives in the Library Functions Manual and it's genuinely one of the cutest little functions in libcurl, no cap π
πΈ NAME πΈ
curl_url_dup β duplicate a URL handle π
π¦ SYNOPSIS π¦
#include <curl/curl.h>
CURLU *curl_url_dup(const CURLU *inhandle);
π DESCRIPTION π
Okay so picture this: you've got a URL object, and you want a twin. Not a reference, not a vibe, an actual copy. That's literally the whole job here π«Ά
curl_url_dup duplicates the URL object that the input CURLU inhandle identifies, and it returns a pointer to that copy as a shiny new CURLU handle β¨
β οΈ bestie listen to me: the new handle also needs to be freed with curl_url_cleanup(3). It's giving "you brought it into this world, you clean it up" π don't ghost it.
π PROTOCOLS π
This functionality affects all supported protocols β every single one, periodt π
π₯ EXAMPLE π₯
int main(void)
{
CURLUcode rc;
CURLU *url = curl_url();
CURLU *url2;
rc = curl_url_set(url, CURLUPART_URL, "https://example.com", 0);
if(!rc) {
url2 = curl_url_dup(url); /* clone it */
curl_url_cleanup(url2);
}
curl_url_cleanup(url);
}
see how url2 gets its own curl_url_cleanup(url2) and url gets its own curl_url_cleanup(url)? two handles, two cleanups, that's the main character energy we're going for πβ¨
β AVAILABILITY β
Added in curl 7.62.0 β a classic, an icon, a legend π
π RETURN VALUE π
Returns a pointer to a new CURLU handleβ¦ or NULL if it's out of memory π (in which case, no handle for you, sorry bestie).
π SEE ALSO π
go read those too, iykyk π they're the whole friend group fr fr
mwah π that's the page β brought to you by libcurl, dated 2026-10-12, and it's curl_url_dup(3) out πβ¨π
π¦ 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