summaryrefslogtreecommitdiff
path: root/protocols/Tox/src
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-05-06 17:21:38 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-05-06 17:21:38 +0000
commitf078926d87c9a272ec9588572d0ec1f53e9b1e2b (patch)
tree0adf6ebcf429902ee159b69b710837935c911502 /protocols/Tox/src
parentb158dd53ea1d868e1fa123206f7ef3c8b54112f3 (diff)
Tox: memleaks fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@16808 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r--protocols/Tox/src/tox_network.cpp4
-rw-r--r--protocols/Tox/src/tox_options.cpp29
2 files changed, 16 insertions, 17 deletions
diff --git a/protocols/Tox/src/tox_network.cpp b/protocols/Tox/src/tox_network.cpp
index 63db87cb5c..13182139f1 100644
--- a/protocols/Tox/src/tox_network.cpp
+++ b/protocols/Tox/src/tox_network.cpp
@@ -64,9 +64,9 @@ void CToxProto::BootstrapNodesFromDb(CToxThread *toxThread, bool isIPv6)
void CToxProto::BootstrapNodesFromJson(CToxThread *toxThread, bool isUdp, bool isIPv6)
{
- char *json = NULL;
+ ptrA json;
- ptrT path(mir_tstrdup((TCHAR*)VARST(_T(TOX_JSON_PATH))));
+ VARST path(_T(TOX_JSON_PATH));
if (!IsFileExists(path))
UpdateNodes();
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp
index 30227f1b7f..f65f575c50 100644
--- a/protocols/Tox/src/tox_options.cpp
+++ b/protocols/Tox/src/tox_options.cpp
@@ -307,7 +307,7 @@ void CToxNodeEditor::OnInitDialog()
lvi.mask = LVIF_TEXT;
lvi.iItem = m_iItem;
lvi.cchTextMax = MAX_PATH;
- lvi.pszText = (TCHAR*)mir_alloc(MAX_PATH * sizeof(TCHAR));
+ lvi.pszText = (TCHAR*)alloca(MAX_PATH * sizeof(TCHAR));
lvi.iSubItem = 0;
m_list->GetItem(&lvi);
@@ -324,8 +324,6 @@ void CToxNodeEditor::OnInitDialog()
lvi.iSubItem = 3;
m_list->GetItem(&lvi);
m_pkey.SetText(lvi.pszText);
-
- mir_free(lvi.pszText);
}
Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULE, "EditNodeDlg");
@@ -429,7 +427,7 @@ void CToxOptionsNodeList::OnAddNode(CCtrlBase*)
{
CToxNodeEditor nodeEditor(-1, &m_nodes);
if (nodeEditor.DoModal())
- SendMessage(GetParent(m_hwnd), PSM_CHANGED, 0, 0);
+ NotifyChange();
}
void CToxOptionsNodeList::OnUpdateNodes(CCtrlBase*)
@@ -451,7 +449,7 @@ void CToxOptionsNodeList::OnNodeListDoubleClick(CCtrlBase*)
{
CToxNodeEditor nodeEditor(lvi.iItem, &m_nodes);
if (nodeEditor.DoModal())
- SendMessage(GetParent(m_hwnd), PSM_CHANGED, 0, 0);
+ NotifyChange();
}
}
@@ -466,14 +464,14 @@ void CToxOptionsNodeList::OnNodeListClick(CCtrlListView::TEventInfo *evt)
{
CToxNodeEditor nodeEditor(lvi.iItem, &m_nodes);
if (nodeEditor.DoModal())
- SendMessage(GetParent(GetParent(m_hwnd)), PSM_CHANGED, 0, 0);
+ NotifyChange();
}
else if (lvi.iGroupId && lvi.iSubItem == 5)
{
if (MessageBox(m_hwnd, TranslateT("Are you sure?"), TranslateT("Node deleting"), MB_YESNO | MB_ICONWARNING) == IDYES)
{
m_nodes.DeleteItem(lvi.iItem);
- SendMessage(GetParent(m_hwnd), PSM_CHANGED, 0, 0);
+ NotifyChange();
}
}
}
@@ -490,7 +488,7 @@ void CToxOptionsNodeList::OnNodeListKeyDown(CCtrlListView::TEventInfo *evt)
if (MessageBox(GetParent(m_hwnd), TranslateT("Are you sure?"), TranslateT("Node deleting"), MB_YESNO | MB_ICONWARNING) == IDYES)
{
m_nodes.DeleteItem(lvi.iItem);
- SendMessage(GetParent(m_hwnd), PSM_CHANGED, 0, 0);
+ NotifyChange();
}
}
}
@@ -501,10 +499,10 @@ void CToxOptionsNodeList::ReloadNodeList()
int iItem = -1;
- ptrT path(mir_tstrdup((TCHAR*)VARST(_T(TOX_JSON_PATH))));
+ VARST path(_T(TOX_JSON_PATH));
if (CToxProto::IsFileExists(path))
{
- char *json = NULL;
+ ptrA json;
FILE *hFile = _tfopen(path, L"r");
if (hFile != NULL)
@@ -527,17 +525,17 @@ void CToxOptionsNodeList::ReloadNodeList()
{
JSONNode node = nodes[i];
- TCHAR *ipv4 = mir_utf8decodeT(node.at("ipv4").as_string().c_str());
+ ptrT ipv4(mir_utf8decodeT(node.at("ipv4").as_string().c_str()));
iItem = m_nodes.AddItem(ipv4, -1, NULL, 0);
- TCHAR *ipv6 = mir_utf8decodeT(node.at("ipv6").as_string().c_str());
+ ptrT ipv6(mir_utf8decodeT(node.at("ipv6").as_string().c_str()));
if (mir_tstrcmp(ipv6, _T("-")))
m_nodes.SetItem(iItem, 1, ipv6);
- TCHAR *port = mir_utf8decodeT(node.at("port").as_string().c_str());
+ ptrT port(mir_utf8decodeT(node.at("port").as_string().c_str()));
m_nodes.SetItem(iItem, 2, port);
- TCHAR *pubKey = mir_utf8decodeT(node.at("public_key").as_string().c_str());
+ ptrT pubKey(mir_utf8decodeT(node.at("public_key").as_string().c_str()));
m_nodes.SetItem(iItem, 3, pubKey);
}
}
@@ -578,10 +576,11 @@ void CToxOptionsNodeList::ReloadNodeList()
void CToxOptionsNodeList::OnApply()
{
char setting[MAX_PATH];
+ TCHAR tszText[MAX_PATH];
LVITEM lvi = { 0 };
lvi.cchTextMax = MAX_PATH;
- lvi.pszText = (TCHAR*)mir_alloc(MAX_PATH * sizeof(TCHAR));
+ lvi.pszText = tszText;
char module[MAX_PATH];
mir_snprintf(module, "%s_Nodes", m_proto->m_szModuleName);