Skip to content

Lwip wrapper memory issues #153

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added move constructor
  • Loading branch information
andreagilardoni committed Sep 28, 2023
commit 3f1ee3a1df6a526e87153bef389b90c3a5d3d2ba
18 changes: 18 additions & 0 deletions libraries/lwIpWrapper/src/lwipClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ lwipClient::lwipClient(struct tcp_struct* tcpClient)
: _tcp_client(tcpClient), _provided_tcp_client(true)

{
}

/* -------------------------------------------------------------------------- */
lwipClient::lwipClient(lwipClient&& c) noexcept
:_tcp_client(std::move(c._tcp_client)), _provided_tcp_client(c._provided_tcp_client), _timeout(c._timeout)
{

}
/* -------------------------------------------------------------------------- */

Expand All @@ -42,6 +49,17 @@ lwipClient::~lwipClient()
}
/* -------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------- */
lwipClient& lwipClient::operator=(lwipClient&& c) {
this->_tcp_client = std::move(c._tcp_client);
this->_provided_tcp_client = c._provided_tcp_client;
this->_timeout = c._timeout;

return *this;
}

/* -------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------- */
int lwipClient::connect(const char* host, uint16_t port)
{
Expand Down
5 changes: 4 additions & 1 deletion libraries/lwIpWrapper/src/lwipClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ class lwipClient : public Client {
lwipClient();
lwipClient(uint8_t sock);
lwipClient(struct tcp_struct* tcpClient);
lwipClient(lwipClient&& c);
virtual ~lwipClient();

lwipClient& operator=(lwipClient&& c);

uint8_t status();
virtual int connect(IPAddress ip, uint16_t port);
virtual int connect(const char* host, uint16_t port);
Expand Down Expand Up @@ -70,7 +73,7 @@ class lwipClient : public Client {
struct tcp_struct* _tcp_client;
uint16_t _timeout = 10000;

const bool _provided_tcp_client;
bool _provided_tcp_client;
};

#endif