Commit baee4ee7 authored by Gabriel Margiani's avatar Gabriel Margiani
Browse files

fix two memory leaks and clear mqs befor usage

parent ffbca4e1
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -25,16 +25,17 @@ namespace p3 {
	class perror : std::exception {
		std::string context;
		std::string error;
		std::string message;

		public:
			perror(std::string c, std::string e) : context(c), error(e) {};
			perror(std::string c, std::string e) : context(c), error(e), message(c + ": " + e) {};
			~perror() throw () {};

			const char * getContext() { return context.c_str(); }
			const char * getError() { return error.c_str(); }

			const char* what() const throw() {
				return (context + ": " + error).c_str();
				return message.c_str();
			}
	};
}
+4 −0
Original line number Diff line number Diff line
@@ -38,6 +38,10 @@ p3::mQueue::mQueue(const std::string& id, bool c, bool p) :
		flags |= O_CREAT;
		inkey = key + "-2";
		outkey = key + "-1";

		// Make sure our queues are clean
		mq_unlink(inkey.c_str());
		mq_unlink(outkey.c_str());
	} else {
		inkey = key + "-1";
		outkey = key + "-2";
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ p3::sipphone::~sipphone() {

void p3::sipphone::register_thread(const std::string& id) {
	std::lock_guard<std::mutex> g(threads_mutex);
	pj_thread_desc* ptd = new pj_thread_desc[1];
	pj_thread_desc* ptd = new pj_thread_desc[1]();
	pj_thread_t* tptr;
	pj_thread_register(id.c_str(), *ptd, &tptr);
	pj_threads[id] = { tptr, ptd };