-extern int
-get_utf16le_string(const tchar *name, utf16lechar **name_utf16le_ret,
- u16 *name_utf16le_nbytes_ret);
+/* Convert a string in the platform-dependent encoding to UTF-16LE, but if both
+ * encodings are UTF-16LE, simply re-use the string. Release with
+ * tstr_put_utf16le() when done. */
+static inline int
+tstr_get_utf16le_and_len(const tchar *tstr,
+ const utf16lechar **ustr_ret, size_t *usize_ret)
+{
+ size_t tsize = tstrlen(tstr) * sizeof(tchar);
+#if TCHAR_IS_UTF16LE
+ /* No conversion or copy needed */
+ *ustr_ret = tstr;
+ *usize_ret = tsize;
+ return 0;
+#else
+ return tstr_to_utf16le(tstr, tsize, (utf16lechar **)ustr_ret, usize_ret);
+#endif
+}
+
+/* Convert a string in the platform-dependent encoding to UTF-16LE, but if both
+ * encodings are UTF-16LE, simply re-use the string. Release with
+ * tstr_put_utf16le() when done. */
+static inline int
+tstr_get_utf16le(const tchar *tstr, const utf16lechar **ustr_ret)
+{
+#if TCHAR_IS_UTF16LE
+ /* No conversion or copy needed */
+ *ustr_ret = tstr;
+ return 0;
+#else
+ size_t tsize = tstrlen(tstr) * sizeof(tchar);
+ size_t dummy;
+ return tstr_to_utf16le(tstr, tsize, (utf16lechar **)ustr_ret, &dummy);
+#endif
+}