aboutsummaryrefslogtreecommitdiff
path: root/c/datalistview.cpp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-07-16 01:53:49 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-07-16 01:53:49 +0200
commit2fed063bf167dcb8f900c4a1f11b0a02ae115d16 (patch)
tree99b41b649fb6a1b6683bd90cd38ab894dd526ce3 /c/datalistview.cpp
parent84c3dd3587e219caa80adc2070f0e9fe004c27bc (diff)
downloadEpisodeBrowser-2fed063bf167dcb8f900c4a1f11b0a02ae115d16.tar.gz
Rewrite TszFromSz as TsmFromSz.
I.e. using std::basic_string<TCHAR> instead of TCHAR *. This removes all unmanaged frees.
Diffstat (limited to 'c/datalistview.cpp')
-rw-r--r--c/datalistview.cpp14
1 files changed, 4 insertions, 10 deletions
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<TCHAR> tsmKey = TsmFromSz(szKey, CP_UTF8);
+ std::basic_string<TCHAR> 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);