Skip to content

Singleton initializer issue #135

Description

@pipawoz

Hi, im trying to do something similar to the recv_header.cpp example but inside of a class.

I have no issue with compile/link but when running my class i get memory issues here:

// curl_interface.h
// Implementation of the singleton initializer
template<class T> curl_interface<T>::global_initializer::global_initializer(const long flag) {
    const CURLcode code = curl_global_init(flag);
    if (code != CURLE_OK) {
        throw curl_easy_exception(code,__FUNCTION__);
    }
}

Exception has occurred: W32/0xC0000374
Unhandled exception at 0x00007FFCC208F199 (ntdll.dll) in main.exe: 0xC0000374

My class is like:

class CurlCppClient
{
  private:
    std::ostringstream body_var;
    std::ostringstream header_var;
    curl::curl_ios<std::ostringstream> body;
    curl::curl_ios<std::ostringstream> header;
    curl::curl_easy curl_handler;
    ....
  public:
    ...
}

CurlCppClient::CurlCppClient()
  : body{header_var}, header{body_var}
{
  curl_handler.add<CURLOPT_WRITEFUNCTION>(header.get_function());
  curl_handler.add<CURLOPT_HEADERDATA>(header.get_stream());
  curl_handler.add<CURLOPT_WRITEDATA>(body.get_stream());
  ...
}

I have no issue if I only use one std::ostringstream like in easy_info.cpp but once i add the second std::ostringstream (even if i dont set the write function) it fails at the singleton.

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions