1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: curl_share_init 5Section: 3 6Source: libcurl 7See-also: 8 - curl_share_cleanup (3) 9 - curl_share_setopt (3) 10--- 11 12# NAME 13 14curl_share_init - Create a shared object 15 16# SYNOPSIS 17 18~~~c 19#include <curl/curl.h> 20 21CURLSH *curl_share_init(); 22~~~ 23 24# DESCRIPTION 25 26This function returns a pointer to a *CURLSH* handle to be used as input 27to all the other share-functions, sometimes referred to as a share handle in 28some places in the documentation. This init call MUST have a corresponding 29call to curl_share_cleanup(3) when all operations using the share are 30complete. 31 32This *share handle* is what you pass to curl using the 33CURLOPT_SHARE(3) option with curl_easy_setopt(3), to make that 34specific curl handle use the data in this share. 35 36# EXAMPLE 37 38~~~c 39int main(void) 40{ 41 CURLSHcode sh; 42 CURLSH *share = curl_share_init(); 43 sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT); 44 if(sh) 45 printf("Error: %s\n", curl_share_strerror(sh)); 46} 47~~~ 48 49# AVAILABILITY 50 51Added in 7.10 52 53# RETURN VALUE 54 55If this function returns NULL, something went wrong (out of memory, etc.) 56and therefore the share object was not created. 57