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

fix: fix memory leak during network disconnect #82

Merged
merged 2 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions make-libmqttclient.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash

current_pwd=$(
cd "$(dirname "$0")"
Expand Down Expand Up @@ -36,7 +36,7 @@ INC = -lpthread \\
-I$current_pwd/mqttclient \\
-I$current_pwd/network \\
-I$current_pwd/platform/linux \\
-I$current_pwd/test
-I$current_pwd/config

OBJS = \$(patsubst %.c, %.o, \$(SRC))

Expand Down Expand Up @@ -64,7 +64,7 @@ EOF

fi

mkdir -p $current_pwd/libmqttclient/include/test/.
mkdir -p $current_pwd/libmqttclient/include/config/.
mkdir -p $current_pwd/libmqttclient/include/mqtt/.
mkdir -p $current_pwd/libmqttclient/include/common/.
mkdir -p $current_pwd/libmqttclient/include/network/.
Expand All @@ -74,7 +74,7 @@ mkdir -p $current_pwd/libmqttclient/include/platform/linux/.
mkdir -p $current_pwd/libmqttclient/include/mbedtls/.
mkdir -p $current_pwd/libmqttclient/include/mbedtls/wrapper/.

cp -r $current_pwd/test/*.h $current_pwd/libmqttclient/include/test/.
cp -r $current_pwd/config/*.h $current_pwd/libmqttclient/include/config/.
cp -r $current_pwd/mqtt/*.h $current_pwd/libmqttclient/include/mqtt/.
cp -r $current_pwd/common/*.h $current_pwd/libmqttclient/include/common/.
cp -r $current_pwd/network/*.h $current_pwd/libmqttclient/include/network/.
Expand Down
5 changes: 3 additions & 2 deletions network/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ int network_init(network_t *n, const char *host, const char *port, const char *c
void network_release(network_t* n)
{
if (n->socket >= 0)
{
network_disconnect(n);

memset(n, 0, sizeof(network_t));
memset(n, 0, sizeof(network_t));
}
}

void network_set_channel(network_t *n, int channel)
Expand Down