Skip to content

Commit ab8ddd9

Browse files
committed
Initialize certain global variables
1 parent 5190b18 commit ab8ddd9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/elf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "defs.h"
1212
#include "globals.c"
1313

14-
int elf_symbol_index;
14+
int elf_symbol_index = 0;
1515

1616
void elf_write_str(strbuf_t *elf_array, const char *vals)
1717
{

src/globals.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ char *intern_string(char *str);
1818

1919
/* Lexer */
2020
char token_str[MAX_TOKEN_LEN];
21-
token_t next_token;
22-
char next_char;
21+
token_t next_token = 0;
22+
char next_char = 0;
2323
bool skip_newline = true;
2424

2525
/* Token memory management */
@@ -32,7 +32,7 @@ bool preproc_match;
3232
/* Point to the first character after where the macro has been called. It is
3333
* needed when returning from the macro body.
3434
*/
35-
int macro_return_idx;
35+
int macro_return_idx = 0;
3636

3737
/* Global objects */
3838

@@ -1236,6 +1236,9 @@ void strbuf_free(strbuf_t *src)
12361236
*/
12371237
void global_init(void)
12381238
{
1239+
FUNC_LIST.head = NULL;
1240+
FUNC_LIST.tail = NULL;
1241+
memset(REGS, 0, sizeof(regfile_t) * REG_CNT);
12391242
MACROS_MAP = hashmap_create(MAX_ALIASES);
12401243

12411244
/* Initialize arenas first so we can use them for allocation */

0 commit comments

Comments
 (0)