Skip to content

Commit

Permalink
Merge pull request #82 from wuhaogs/fix_wuhaogs_b1
Browse files Browse the repository at this point in the history
fix: fix memory leak during network disconnect
  • Loading branch information
jiejieTop authored Dec 2, 2023
2 parents 186ac95 + 04994c0 commit 956e0c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
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

0 comments on commit 956e0c8

Please sign in to comment.