Skip to content

Commit

Permalink
fixup! http: optionally load libcurl lazily
Browse files Browse the repository at this point in the history
An upcoming change in Git wants it to call `curl_version_info()`, which
the lazy cURL stuff hereby learns about.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Aug 13, 2024
1 parent 28481d4 commit 6fe9491
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions compat/lazyload-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ static func_t load_function(void *handle, const char *name)
}
#endif

typedef struct curl_version_info_data *(*curl_version_info_type)(CURLversion version);
static curl_version_info_type curl_version_info_func;

typedef char *(*curl_easy_escape_type)(CURL *handle, const char *string, int length);
static curl_easy_escape_type curl_easy_escape_func;

Expand Down Expand Up @@ -192,6 +195,7 @@ static void lazy_load_curl(void)
if (!libcurl)
die("failed to load library '%s'", LIBCURL_FILE_NAME("libcurl"));

curl_version_info_func = (curl_version_info_type)load_function(libcurl, "curl_version_info");
curl_easy_escape_func = (curl_easy_escape_type)load_function(libcurl, "curl_easy_escape");
curl_free_func = (curl_free_type)load_function(libcurl, "curl_free");
curl_global_init_func = (curl_global_init_type)load_function(libcurl, "curl_global_init");
Expand Down Expand Up @@ -225,6 +229,12 @@ static void lazy_load_curl(void)
curl_easy_setopt_off_t_func = (curl_easy_setopt_off_t_type)curl_easy_setopt_func;
}

struct curl_version_info_data *curl_version_info(CURLversion version)
{
lazy_load_curl();
return curl_version_info_func(version);
}

char *curl_easy_escape(CURL *handle, const char *string, int length)
{
lazy_load_curl();
Expand Down

0 comments on commit 6fe9491

Please sign in to comment.