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