#include "curl_memory.h"
#include "memdebug.h"
+void curl_version_init();
+
/* win32_cleanup() is for win32 socket cleanup functionality, the opposite
of win32_init() */
static void win32_cleanup(void)
if(flags & CURL_GLOBAL_ACK_EINTR)
Curl_ack_eintr = 1;
- init_flags = flags;
+ init_flags = flags;
+
+ curl_version_init();
return CURLE_OK;
}
#define CURL_LIBSSH2_VERSION LIBSSH2_VERSION
#endif
+/* For thread safety purposes this function is called by global_init so that
+ the static data in both version functions is initialized. */
+void curl_version_init()
+{
+ curl_version();
+ curl_version_info(CURLVERSION_NOW);
+}
+
char *curl_version(void)
{
+ static bool initialized;
static char version[200];
char *ptr = version;
size_t len;
size_t left = sizeof(version);
+ if(initialized)
+ return version;
+
strcpy(ptr, LIBCURL_NAME "/" LIBCURL_VERSION);
len = strlen(ptr);
left -= len;
}
#endif
+ initialized = true;
return version;
}
curl_version_info_data *curl_version_info(CURLversion stamp)
{
+ static bool initialized;
#ifdef USE_LIBSSH2
static char ssh_buffer[80];
#endif
-
#ifdef USE_SSL
static char ssl_buffer[80];
+#endif
+
+ if(initialized)
+ return &version_info;
+
+#ifdef USE_SSL
Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
version_info.ssl_version = ssl_buffer;
#endif
(void)stamp; /* avoid compiler warnings, we don't use this */
+ initialized = true;
return &version_info;
}