1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: curl_url_dup 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_CURLU (3) 9 - curl_url (3) 10 - curl_url_cleanup (3) 11 - curl_url_get (3) 12 - curl_url_set (3) 13Protocol: 14 - All 15Added-in: 7.62.0 16--- 17 18# NAME 19 20curl_url_dup - duplicate a URL handle 21 22# SYNOPSIS 23 24~~~c 25#include <curl/curl.h> 26 27CURLU *curl_url_dup(const CURLU *inhandle); 28~~~ 29 30# DESCRIPTION 31 32Duplicates the URL object the input *CURLU* *inhandle* identifies and 33returns a pointer to the copy as a new *CURLU* handle. The new handle also 34needs to be freed with curl_url_cleanup(3). 35 36# %PROTOCOLS% 37 38# EXAMPLE 39 40~~~c 41int 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 59Returns a new handle or NULL if out of memory. 60