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/pl.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'c/pl.cpp') diff --git a/c/pl.cpp b/c/pl.cpp index ace83e7..c944547 100644 --- a/c/pl.cpp +++ b/c/pl.cpp @@ -1,3 +1,4 @@ +#include #include #include "pl.h" @@ -33,6 +34,20 @@ int Query::NextSolution() return 0; } +int PL_get_tchars(term_t t, TCHAR **lpTsz, int iFlags) +{ +#ifdef UNICODE + size_t sizLen; + if (!PL_get_wchars(t, &sizLen, lpTsz, iFlags)) + return 0; + return sizLen; +#else + if (!PL_get_chars(t, lpTsz, iFlags)) + return 0; + return -1; +#endif +} + int Plx(const char *szMod, const char *szPred) { term_t t = PL_new_term_refs(0); -- cgit v1.2.3