class A { public: A() { m_ = malloc(10); } ~A() { free(m_); } private: void* m_; }; void WorkerThread(void* v) { A a; // Line 37 }
What could I place after the comment "// Line 37" to make the code leak 10 bytes of memory for every worker thread I created?
Comments
-Chikuru
ExitThread(0);
From MSDN:
ExitThread is the preferred method of exiting a thread in C code. However, in C++ code, the thread is exited before any destructors can be called or any other automatic cleanup can be performed. Therefore, in C++ code, you should return from your thread function.
-DM