From 2fed063bf167dcb8f900c4a1f11b0a02ae115d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 16 Jul 2022 01:53:49 +0200 Subject: Rewrite TszFromSz as TsmFromSz. I.e. using std::basic_string instead of TCHAR *. This removes all unmanaged frees. --- c/datalistview.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'c/datalistview.cpp') diff --git a/c/datalistview.cpp b/c/datalistview.cpp index 2920c0c..2f184dc 100644 --- a/c/datalistview.cpp +++ b/c/datalistview.cpp @@ -46,29 +46,23 @@ void DataListView::ShowEpisode(int iEpisode) for (int i = 0; PL_next_solution(q); i++) { char *szKey; char *szValue; - TCHAR *tszKey, *tszValue; if (!(PL_get_atom_chars(t+1,&szKey) && PL_get_atom_chars(t+2,&szValue))) continue; - tszKey = TszFromSz(szKey, CP_UTF8); - if (!tszKey) continue; - tszValue = TszFromSz(szValue, CP_UTF8); - if (!tszValue) goto c; + std::basic_string tsmKey = TsmFromSz(szKey, CP_UTF8); + std::basic_string tsmValue = TsmFromSz(szValue, CP_UTF8); lviKey.mask = LVIF_TEXT; lviKey.iItem = i; lviKey.iSubItem = 0; - lviKey.pszText = tszKey; + lviKey.pszText = tsmKey.data(); ListView_InsertItem(m_hWnd, &lviKey); lviValue.iItem = i; lviValue.iSubItem = 1; - lviValue.pszText = tszValue; + lviValue.pszText = tsmValue.data(); ListView_SetItem(m_hWnd, &lviValue); - - free(tszValue); - c: free(tszKey); } PL_cut_query(q); -- cgit v1.2.3