Skip to content

Commit 68dd3c8

Browse files
author
karl
committed
define wchar size as 4, this fixes #607
wchar_t is 4 bytes on linux, but only 2 on windows this causes issues since we use unicde chars that are more than 2 bytes long
1 parent 1936638 commit 68dd3c8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

output/terminal_noncurses.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <wchar.h>
1818

1919
#define MAX_GRADIENT_COLOR_DEFS 8
20+
#define WCHAR_SIZE 4 // wchar is 4 bytes on linux but only 2 on windows, we need at least 3
2021

2122
wchar_t *frame_buffer;
2223
wchar_t *barstring[8];
@@ -122,15 +123,15 @@ int init_terminal_noncurses(int tty, char *const fg_color_string, char *const bg
122123
}
123124
} else if (!tty) {
124125

125-
buf_length = sizeof(wchar_t) * width * lines * 10;
126+
buf_length = WCHAR_SIZE * width * lines * 10;
126127
frame_buffer = (wchar_t *)malloc(buf_length);
127-
spacestring = (wchar_t *)malloc(sizeof(wchar_t) * (bar_width + 1));
128+
spacestring = (wchar_t *)malloc(WCHAR_SIZE * (bar_width + 1));
128129

129130
// clearing barstrings
130131
for (int n = 0; n < 8; n++) {
131-
barstring[n] = (wchar_t *)malloc(sizeof(wchar_t) * (bar_width + 1));
132+
barstring[n] = (wchar_t *)malloc(WCHAR_SIZE * (bar_width + 1));
132133
barstring[n][0] = '\0';
133-
top_barstring[n] = (wchar_t *)malloc(sizeof(wchar_t) * (bar_width + 1));
134+
top_barstring[n] = (wchar_t *)malloc(WCHAR_SIZE * (bar_width + 1));
134135
top_barstring[n][0] = '\0';
135136
}
136137
spacestring[0] = '\0';

0 commit comments

Comments
 (0)