From 7027f66a9aa944a683caadc4e632738a3c8a9ba3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 Dec 2020 16:57:16 +0100 Subject: [PATCH] Simplify code by folding {Initialize,Cleanu[}CURL() in the caller There doesn't seem to be any need to have separate functions when they are just trivial wrappers. --- include/wx/webrequest_curl.h | 4 ---- src/common/webrequest_curl.cpp | 21 +++++---------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/include/wx/webrequest_curl.h b/include/wx/webrequest_curl.h index 2033b65d10..aa6b1c7c7d 100644 --- a/include/wx/webrequest_curl.h +++ b/include/wx/webrequest_curl.h @@ -137,10 +137,6 @@ private: static int ms_activeSessions; - static void InitializeCURL(); - - static void CleanupCURL(); - wxDECLARE_NO_COPY_CLASS(wxWebSessionCURL); }; diff --git a/src/common/webrequest_curl.cpp b/src/common/webrequest_curl.cpp index e3f01b60be..cf0e67a999 100644 --- a/src/common/webrequest_curl.cpp +++ b/src/common/webrequest_curl.cpp @@ -346,7 +346,10 @@ wxWebSessionCURL::wxWebSessionCURL() : { // Initialize CURL globally if no sessions are active if ( ms_activeSessions == 0 ) - InitializeCURL(); + { + if ( curl_global_init(CURL_GLOBAL_ALL) ) + wxLogError("libcurl could not be initialized"); + } ms_activeSessions++; } @@ -370,7 +373,7 @@ wxWebSessionCURL::~wxWebSessionCURL() // Global CURL cleanup if this is the last session --ms_activeSessions; if ( ms_activeSessions == 0 ) - CleanupCURL(); + curl_global_cleanup(); } void wxWebSessionCURL::Initialize() @@ -534,18 +537,4 @@ wxVersionInfo wxWebSessionCURL::GetLibraryVersionInfo() desc); } -// static -void wxWebSessionCURL::InitializeCURL() -{ - if ( curl_global_init(CURL_GLOBAL_ALL) ) - wxLogError("libcurl could not be initialized"); -} - -// static -void wxWebSessionCURL::CleanupCURL() -{ - if ( ms_activeSessions == 0 ) - curl_global_cleanup(); -} - #endif // wxUSE_WEBREQUEST_CURL