]> git.sur5r.net Git - i3/i3/blobdiff - libi3/ucs2_conversion.c
Fix redundant casts to the same type
[i3/i3] / libi3 / ucs2_conversion.c
index 6f7cf28749a50a966459ceadc4b383fb3caa69d1..398c1ae58112566da771035a578ce222f99d2a8e 100644 (file)
@@ -2,17 +2,17 @@
  * vim:ts=4:sw=4:expandtab
  *
  * i3 - an improved dynamic tiling window manager
- * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
+ * © 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 * sizeof(char));
+    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;
@@ -42,8 +42,8 @@ char *convert_ucs2_to_utf8(xcb_char2b_t *text, size_t num_glyphs) {
 
     /* Do the conversion */
     size_t input_len = num_glyphs * sizeof(xcb_char2b_t);
-    size_t rc = iconv(utf8_conversion_descriptor, (char**)&text,
-            &input_len, &output, &output_size);
+    size_t rc = iconv(utf8_conversion_descriptor, (char **)&text,
+                      &input_len, &output, &output_size);
     if (rc == (size_t)-1) {
         perror("Converting to UTF-8 failed");
         free(buffer);
@@ -83,8 +83,7 @@ xcb_char2b_t *convert_utf8_to_ucs2(char *input, size_t *real_strlen) {
     }
 
     /* Do the conversion */
-    size_t rc = iconv(ucs2_conversion_descriptor, (char**)&input,
-            &input_size, (char**)&output, &output_size);
+    size_t rc = iconv(ucs2_conversion_descriptor, &input, &input_size, (char **)&output, &output_size);
     if (rc == (size_t)-1) {
         perror("Converting to UCS-2 failed");
         free(buffer);