diff options
-rw-r--r-- | include/curl_wrapper.hpp | 18 | ||||
-rw-r--r-- | src/curl_wrapper.cpp | 15 |
2 files changed, 13 insertions, 20 deletions
diff --git a/include/curl_wrapper.hpp b/include/curl_wrapper.hpp index 328c3b9..5e5b0fa 100644 --- a/include/curl_wrapper.hpp +++ b/include/curl_wrapper.hpp @@ -26,9 +26,6 @@ namespace mastodonpp using std::string; -//! Internal use only. -extern bool curl_initialized; - /*! * @brief Handles the details of network connections. * @@ -40,10 +37,9 @@ class CURLWrapper { public: /*! - * @brief Constructs a CURLWrapper object. + * @brief Initializes curl and sets up connection. * - * The first construction of an CurlWrapper object will call - * `curl_global_init`, which is not thread-safe. For more information + * Calls `curl_global_init`, which is not thread-safe. For more information * consult [curl_global_init(3)] * (https://curl.haxx.se/libcurl/c/curl_global_init.html). * @@ -57,7 +53,15 @@ public: //! Move constructor CURLWrapper(CURLWrapper &&other) noexcept = default; - //! Destructor + /*! + * @brief Cleans up curl and connection. + * + * Calls `curl_global_cleanup`, which is not thread-safe. For more + * information consult [curl_global_cleanup(3)] + * (https://curl.haxx.se/libcurl/c/curl_global_cleanup.html). + * + * @since 0.1.0 + */ virtual ~CURLWrapper() noexcept; //! Copy assignment operator diff --git a/src/curl_wrapper.cpp b/src/curl_wrapper.cpp index ef724b9..068f0ea 100644 --- a/src/curl_wrapper.cpp +++ b/src/curl_wrapper.cpp @@ -20,28 +20,17 @@ namespace mastodonpp { -bool curl_initialized{false}; - CURLWrapper::CURLWrapper() : _curl_buffer_error{} { - if (!curl_initialized) - { - curl_global_init(CURL_GLOBAL_ALL); // NOLINT(hicpp-signed-bitwise) - curl_initialized = true; - } + curl_global_init(CURL_GLOBAL_ALL); // NOLINT(hicpp-signed-bitwise) _connection = curl_easy_init(); setup_curl(); } CURLWrapper::~CURLWrapper() noexcept { curl_easy_cleanup(_connection); - - if (curl_initialized) - { - curl_global_cleanup(); - curl_initialized = false; - } + curl_global_cleanup(); } int CURLWrapper::writer(char *data, size_t size, size_t nmemb, string *writerData) |