mirror of
https://github.com/moparisthebest/curl
synced 2025-03-11 07:39:50 -04:00
Test and substance patch.
This is my first CVS commit :), what it does: - Makes sure that parts of the cURL library don't get initialized twice - Makes sure that we only free what we initialize
This commit is contained in:
parent
f8d94a3849
commit
e051f904f2
15
lib/easy.c
15
lib/easy.c
@ -78,17 +78,27 @@
|
|||||||
#define _MPRINTF_REPLACE /* use our functions only */
|
#define _MPRINTF_REPLACE /* use our functions only */
|
||||||
#include <curl/mprintf.h>
|
#include <curl/mprintf.h>
|
||||||
|
|
||||||
|
/* true globals */
|
||||||
|
static unsigned int initialized = 0;
|
||||||
|
static long init_flags = 0;
|
||||||
|
|
||||||
CURLcode curl_global_init(long flags)
|
CURLcode curl_global_init(long flags)
|
||||||
{
|
{
|
||||||
if(flags & CURL_GLOBAL_SSL)
|
if(flags & CURL_GLOBAL_SSL)
|
||||||
Curl_SSL_init();
|
Curl_SSL_init();
|
||||||
|
|
||||||
|
initialized = 1;
|
||||||
|
init_flags = flags;
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void curl_global_cleanup(void)
|
void curl_global_cleanup(void)
|
||||||
{
|
{
|
||||||
Curl_SSL_cleanup();
|
if (init_flags & CURL_GLOBAL_SSL)
|
||||||
|
Curl_SSL_cleanup();
|
||||||
|
|
||||||
|
initialized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CURL *curl_easy_init(void)
|
CURL *curl_easy_init(void)
|
||||||
@ -97,7 +107,8 @@ CURL *curl_easy_init(void)
|
|||||||
struct UrlData *data;
|
struct UrlData *data;
|
||||||
|
|
||||||
/* Make sure we inited the global SSL stuff */
|
/* Make sure we inited the global SSL stuff */
|
||||||
Curl_SSL_init();
|
if (!initialized)
|
||||||
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
|
|
||||||
/* We use curl_open() with undefined URL so far */
|
/* We use curl_open() with undefined URL so far */
|
||||||
res = Curl_open((CURL **)&data, NULL);
|
res = Curl_open((CURL **)&data, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user