In the destructor, free the memory allocated for elementReader_.partialData.
diff --git a/ndn-cpp/transport/tcp-transport.cpp b/ndn-cpp/transport/tcp-transport.cpp
index 4552cfe..aa438bc 100644
--- a/ndn-cpp/transport/tcp-transport.cpp
+++ b/ndn-cpp/transport/tcp-transport.cpp
@@ -59,4 +59,11 @@
throw std::runtime_error(ndn_getErrorString(error));
}
+TcpTransport::~TcpTransport()
+{
+ if (elementReader_.partialData.array)
+ // Free the memory allocated in connect.
+ free(elementReader_.partialData.array);
+}
+
}
diff --git a/ndn-cpp/transport/tcp-transport.hpp b/ndn-cpp/transport/tcp-transport.hpp
index 9167beb..57d9554 100644
--- a/ndn-cpp/transport/tcp-transport.hpp
+++ b/ndn-cpp/transport/tcp-transport.hpp
@@ -18,6 +18,7 @@
{
ndn_TcpTransport_init(&transport_);
face_ = 0;
+ elementReader_.partialData.array = 0;
}
/**
@@ -47,6 +48,8 @@
*/
virtual void close();
+ ~TcpTransport();
+
private:
struct ndn_TcpTransport transport_;
Face *face_;
diff --git a/ndn-cpp/transport/udp-transport.cpp b/ndn-cpp/transport/udp-transport.cpp
index 6d6f304..4ae9e37 100644
--- a/ndn-cpp/transport/udp-transport.cpp
+++ b/ndn-cpp/transport/udp-transport.cpp
@@ -59,4 +59,11 @@
throw std::runtime_error(ndn_getErrorString(error));
}
+UdpTransport::~UdpTransport()
+{
+ if (elementReader_.partialData.array)
+ // Free the memory allocated in connect.
+ free(elementReader_.partialData.array);
+}
+
}
diff --git a/ndn-cpp/transport/udp-transport.hpp b/ndn-cpp/transport/udp-transport.hpp
index a54839f..17f6e25 100644
--- a/ndn-cpp/transport/udp-transport.hpp
+++ b/ndn-cpp/transport/udp-transport.hpp
@@ -18,6 +18,7 @@
{
ndn_UdpTransport_init(&transport_);
face_ = 0;
+ elementReader_.partialData.array = 0;
}
/**
@@ -47,6 +48,8 @@
*/
virtual void close();
+ ~UdpTransport();
+
private:
struct ndn_UdpTransport transport_;
Face *face_;