~Middle() and ~RestInput() destrcutors added which deletes allocated
memory in Ctors.
Change-Id: I29823cde6c7b28325fde9b40f088f83994ebc6a5
Signed-off-by: Jamal Haidar <jamal.haidar@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1522
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
{
}
+Middle::~Middle()
+{
+ delete m_client;
+ delete m_server;
+ delete m_lineInput;
+ delete m_restInput;
+}
+
void Middle::init()
{
{
public:
Middle();
+ ~Middle();
void init();
void run(int argc, char* argv[]);
using namespace std;
#define BUFLEN 10000
-#define MAX_CONNS 5
static bool enableDebug = false; // set to true to print debug messages
RestInput::RestInput(LineInput *lineInput) : m_lineInput(lineInput)
{
m_data = (char*)malloc(BUFLEN);
- m_thread = new std::thread[MAX_CONNS];
m_threadCount = 0;
}
+RestInput::~RestInput()
+{
+ free(m_data);
+ close(m_sockfd);
+}
+
bool RestInput::init()
{
m_sockfd = socket(AF_INET, SOCK_STREAM, 0);
class RestInput
{
+ static const int MAX_CONNS = 5;
public:
RestInput(LineInput *lineInput);
+ ~RestInput();
bool init();
void startAccept(int &sockfd);
void startThread();
int m_sockfd, m_port, m_threadCount;
struct sockaddr_in m_serverAddr;
char *m_data;
- std::thread *m_thread;
+ std::thread m_thread[MAX_CONNS];
};
#endif // RESTINPUT_H