Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singleton initializer issue #135

Open
pipawoz opened this issue Oct 21, 2021 · 1 comment
Open

Singleton initializer issue #135

pipawoz opened this issue Oct 21, 2021 · 1 comment

Comments

@pipawoz
Copy link

pipawoz commented Oct 21, 2021

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?

@jinfeihan57
Copy link

Can you upload all you code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants