]> code.delx.au - gnu-emacs/blobdiff - src/coding.c
New C macro AUTO_STRING_WITH_LEN
[gnu-emacs] / src / coding.c
index e72d7b71867a61ef65362185feba56e94e648cf7..bcedd7f5eeb11c6e7f70ec974c8f43415aeb6cac 100644 (file)
@@ -8419,11 +8419,10 @@ from_unicode (Lisp_Object str)
 Lisp_Object
 from_unicode_buffer (const wchar_t *wstr)
 {
-    return from_unicode (
-        make_unibyte_string (
-            (char *) wstr,
-            /* we get one of the two final 0 bytes for free. */
-            1 + sizeof (wchar_t) * wcslen (wstr)));
+  /* We get one of the two final null bytes for free.  */
+  prtdiff_t len = 1 + sizeof (wchar_t) * wcslen (wstr);
+  AUTO_STRING_WITH_LEN (str, (char *) wstr, len);
+  return from_unicode (str);
 }
 
 wchar_t *