]> git.sur5r.net Git - i3/i3/blobdiff - libi3/ucs2_conversion.c
i3test::XTEST: don’t “use i3test” to avoid clobbering state
[i3/i3] / libi3 / ucs2_conversion.c
index 3a7d0194d45f5430ea4d783a897126f8e5f6f0eb..75cff78adbdf4a5739da0834438d3c792105eb0c 100644 (file)
@@ -5,14 +5,14 @@
  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  */
+#include "libi3.h"
+
 #include <err.h>
 #include <errno.h>
 #include <iconv.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "libi3.h"
-
 static iconv_t utf8_conversion_descriptor = (iconv_t)-1;
 static iconv_t ucs2_conversion_descriptor = (iconv_t)-1;
 
@@ -23,8 +23,8 @@ static iconv_t ucs2_conversion_descriptor = (iconv_t)-1;
  */
 char *convert_ucs2_to_utf8(xcb_char2b_t *text, size_t num_glyphs) {
     /* Allocate the output buffer (UTF-8 is at most 4 bytes per glyph) */
-    size_t buffer_size = num_glyphs * 4 * sizeof(char) + 1;
-    char *buffer = scalloc(buffer_size);
+    size_t buffer_size = num_glyphs * 4 + 1;
+    char *buffer = scalloc(buffer_size, 1);
 
     /* We need to use an additional pointer, because iconv() modifies it */
     char *output = buffer;