gnurl_easy_init(3)
π gnurl_easy_init(3) β your lil' intro to the libgnurl Manual, bestie
okay so real talk, this is the first page you're gonna read in the libgnurl Manual and honestly? it's giving opening credits. it's giving "before you do anything else, read this." slay.
β¨ NAME β¨
curl_easy_init β start a libcurl easy session π
πΈ SYNOPSIS πΈ
#include <gnurl/curl.h>
CURL *curl_easy_init( );
π¦ DESCRIPTION π¦
Okay so bestie, listen. This function is literally the first function you must call. Like, before anything else. It hands you back a CURL easy handle, and that handle is what you gotta feed into all the other functions in the easy interface. It's the main character and everyone else is a supporting actor, iykyk.
And this call MUST have a matching call to curl_easy_cleanup(3) when the operation is complete. No cap. You open it, you close it. That's the vibe.
Now, here's the tea β: if you didn't already call curl_global_init(3), then curl_easy_init(3) just goes ahead and does it for you automatically. Which sounds cute and helpful, but this may be lethal in multi-threaded cases, because curl_global_init(3) is not thread-safe, and it may result in resource problems since there's no corresponding cleanup. π Yeah. Not the slay you thought it was.
So you are strongly advised to not allow this automatic behaviour, by calling curl_global_init(3) yourself, properly, like the responsible icon you are. See the description in libcurl(3) of global environment requirements for the details on how to use this function. Go read it. It's important. π«Ά
π RETURN VALUE π
If this function returns NULL, something went wrong and you cannot use the other curl functions. That's it. That's the whole check. Guard it like your life depends on it. π
π EXAMPLE π
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
see how it's got the if(curl) check and the curl_easy_cleanup(curl) at the end? that's the whole lifecycle, bestie. init, setopt, perform, cleanup. iconic. β
π SEE ALSO π
and that's the page fr fr π this lil' slice of wisdom comes to you from libcurl 7.8.1, dated 4 March 2002 β yes she's vintage, yes she still ate, no notes. mwah πβ¨
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms