curl_url_dup.md (1034B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: curl_url_dup 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_CURLU (3) 9 - curl_url (3) 10 - curl_url_cleanup (3) 11 - curl_url_get (3) 12 - curl_url_set (3) 13 Protocol: 14 - All 15 Added-in: 7.62.0 16 --- 17 18 # NAME 19 20 curl_url_dup - duplicate a URL handle 21 22 # SYNOPSIS 23 24 ~~~c 25 #include <curl/curl.h> 26 27 CURLU *curl_url_dup(const CURLU *inhandle); 28 ~~~ 29 30 # DESCRIPTION 31 32 Duplicates the URL object the input *CURLU* *inhandle* identifies and 33 returns a pointer to the copy as a new *CURLU* handle. The new handle also 34 needs to be freed with curl_url_cleanup(3). 35 36 # %PROTOCOLS% 37 38 # EXAMPLE 39 40 ~~~c 41 int main(void) 42 { 43 CURLUcode rc; 44 CURLU *url = curl_url(); 45 CURLU *url2; 46 rc = curl_url_set(url, CURLUPART_URL, "https://example.com", 0); 47 if(!rc) { 48 url2 = curl_url_dup(url); /* clone it */ 49 curl_url_cleanup(url2); 50 } 51 curl_url_cleanup(url); 52 } 53 ~~~ 54 55 # %AVAILABILITY% 56 57 # RETURN VALUE 58 59 Returns a pointer to a new `CURLU` handle or NULL if out of memory.