Skip to content

Commit 83027d4

Browse files
Nakhr11nadsr
authored andcommitted
Fix errors and warnings when compiling with c++.
1 parent 43d40b6 commit 83027d4

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

termbox2.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,8 +2220,8 @@ static int cap_trie_add(const char *cap, uint16_t key, uint8_t mod) {
22202220
if (!next) {
22212221
// We need to add a new child to node
22222222
node->nchildren += 1;
2223-
node->children =
2224-
tb_realloc(node->children, sizeof(*node) * node->nchildren);
2223+
node->children = (struct cap_trie_t *)tb_realloc(node->children,
2224+
sizeof(*node) * node->nchildren);
22252225
if (!node->children) {
22262226
return TB_ERR_MEM;
22272227
}
@@ -2361,7 +2361,7 @@ static int update_term_size_via_esc(void) {
23612361
#define TB_RESIZE_FALLBACK_MS 1000
23622362
#endif
23632363

2364-
char *move_and_report = "\x1b[9999;9999H\x1b[6n";
2364+
char move_and_report[] = "\x1b[9999;9999H\x1b[6n";
23652365
ssize_t write_rv =
23662366
write(global.wfd, move_and_report, strlen(move_and_report));
23672367
if (write_rv != (ssize_t)strlen(move_and_report)) {
@@ -2430,7 +2430,10 @@ static int tb_deinit(void) {
24302430
}
24312431
}
24322432

2433-
sigaction(SIGWINCH, &(struct sigaction){.sa_handler = SIG_DFL}, NULL);
2433+
struct sigaction sa;
2434+
memset(&sa, 0, sizeof(sa));
2435+
sa.sa_handler = SIG_DFL;
2436+
sigaction(SIGWINCH, &sa, NULL);
24342437
if (global.resize_pipefd[0] >= 0) close(global.resize_pipefd[0]);
24352438
if (global.resize_pipefd[1] >= 0) close(global.resize_pipefd[1]);
24362439

@@ -2537,7 +2540,7 @@ static int read_terminfo_path(const char *path) {
25372540
}
25382541

25392542
size_t fsize = st.st_size;
2540-
char *data = tb_malloc(fsize);
2543+
char *data = (char *)tb_malloc(fsize);
25412544
if (!data) {
25422545
fclose(fp);
25432546
return TB_ERR;
@@ -2848,7 +2851,7 @@ static int extract_esc_cap(struct tb_event *event) {
28482851
static int extract_esc_mouse(struct tb_event *event) {
28492852
struct bytebuf_t *in = &global.in;
28502853

2851-
enum type { TYPE_VT200 = 0, TYPE_1006, TYPE_1015, TYPE_MAX };
2854+
enum { TYPE_VT200 = 0, TYPE_1006, TYPE_1015, TYPE_MAX };
28522855

28532856
const char *cmp[TYPE_MAX] = {//
28542857
// X10 mouse encoding, the simplest one
@@ -2860,7 +2863,7 @@ static int extract_esc_mouse(struct tb_event *event) {
28602863
// urxvt: \x1b [ Cb ; Cx ; Cy M
28612864
[TYPE_1015] = "\x1b["};
28622865

2863-
enum type type = 0;
2866+
int type = 0;
28642867
int ret = TB_ERR;
28652868

28662869
// Unrolled at compile-time (probably)
@@ -3358,7 +3361,7 @@ static int cell_free(struct tb_cell *cell) {
33583361
}
33593362

33603363
static int cellbuf_init(struct cellbuf_t *c, int w, int h) {
3361-
c->cells = tb_malloc(sizeof(struct tb_cell) * w * h);
3364+
c->cells = (struct tb_cell *)tb_malloc(sizeof(struct tb_cell) * w * h);
33623365
if (!c->cells) {
33633366
return TB_ERR_MEM;
33643367
}
@@ -3491,9 +3494,9 @@ static int bytebuf_reserve(struct bytebuf_t *b, size_t sz) {
34913494
}
34923495
char *newbuf;
34933496
if (b->buf) {
3494-
newbuf = tb_realloc(b->buf, newcap);
3497+
newbuf = (char *)tb_realloc(b->buf, newcap);
34953498
} else {
3496-
newbuf = tb_malloc(newcap);
3499+
newbuf = (char *)tb_malloc(newcap);
34973500
}
34983501
if (!newbuf) {
34993502
return TB_ERR_MEM;

0 commit comments

Comments
 (0)