From 299f714ed9bd842f38952b94ecdd079da7f93107 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 23 Jul 2022 22:37:11 +0200 Subject: [PATCH] Fix memory allocation using new int HTTPSessionManager. Also small cleanups. --- modules/web/http/http_session_manager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/web/http/http_session_manager.cpp b/modules/web/http/http_session_manager.cpp index 03e93dc36..719f5fab4 100644 --- a/modules/web/http/http_session_manager.cpp +++ b/modules/web/http/http_session_manager.cpp @@ -39,8 +39,7 @@ void HTTPSessionManager::remove_session(Ref session) { for (int i = 0; i < _sessions_vec.size(); ++i) { if (_sessions_vec[i] == session) { - _sessions_vec.write[i] = _sessions_vec[_sessions_vec.size() - 1]; - _sessions_vec.resize(_sessions_vec.size() - 1); + _sessions_vec.remove(i); _mutex.unlock(); return; } @@ -60,8 +59,7 @@ void HTTPSessionManager::delete_session(const String &session_id) { Ref sess = _sessions_vec[i]; if (sess->session_id == session_id) { - _sessions_vec.write[i] = _sessions_vec[_sessions_vec.size() - 1]; - _sessions_vec.resize(_sessions_vec.size() - 1); + _sessions_vec.remove(i); break; } @@ -124,7 +122,8 @@ Ref HTTPSessionManager::get_session(const String &session_id) { } Ref HTTPSessionManager::create_session() { - Ref session = new HTTPSession(); + Ref session; + session.instance(); while (true) { session->session_id = generate_session_id(session->session_id); @@ -163,7 +162,8 @@ void HTTPSessionManager::load_sessions() { int id = r->get_cell_int(0); String session_id = r->get_cell(1); - Ref s = new HTTPSession(); + Ref s; + s.instance(); s->id = id; s->session_id = session_id;