# include "config.h"
#endif
+#include <errno.h>
+#include <iconv.h>
+#include <pthread.h>
+#include <string.h>
+
#include "wimlib.h"
+#include "wimlib/alloca.h"
#include "wimlib/assert.h"
#include "wimlib/encoding.h"
#include "wimlib/endianness.h"
#include "wimlib/list.h"
#include "wimlib/util.h"
-#include <errno.h>
-#include <iconv.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef HAVE_ALLOCA_H
-# include <alloca.h>
-#endif
bool wimlib_mbs_is_utf8 = !TCHAR_IS_UTF16LE;
return (n1 < n2) ? -1 : 1;
}
-/* Duplicate a UTF16-LE string which may not be null-terminated. */
+/* Duplicate a UTF16-LE string. The input string might not be null terminated
+ * and might be misaligned, but the returned string is guaranteed to be null
+ * terminated and properly aligned. */
utf16lechar *
-utf16le_dupz(const utf16lechar *ustr, size_t usize)
+utf16le_dupz(const void *ustr, size_t usize)
{
utf16lechar *dup = MALLOC(usize + sizeof(utf16lechar));
if (dup) {