Compare commits

...

2 commits

Author SHA1 Message Date
XOR
89efb81f3e Remove print statements used for debugging 2023-09-21 23:42:45 +02:00
XOR
6238291ab3 Fix memory leak 2023-09-21 23:39:50 +02:00
2 changed files with 2 additions and 5 deletions

View file

@ -12,8 +12,6 @@ void build_label_table(char label_tokens[][MAX_TOKEN_SIZE], shash_hashtable_t *l
{ {
if(label_tokens[token_index][0] == '$') if(label_tokens[token_index][0] == '$')
{ {
printf("Found label: %s\n", label_tokens[token_index]+1);
//Store the adress we are at on the heap, as the hashtable only stores pointers to data //Store the adress we are at on the heap, as the hashtable only stores pointers to data
unsigned int *heap_pointer_to_adress = malloc(sizeof(instruction_index)); unsigned int *heap_pointer_to_adress = malloc(sizeof(instruction_index));
*heap_pointer_to_adress = instruction_index; *heap_pointer_to_adress = instruction_index;

View file

@ -143,7 +143,6 @@ int main(int argc, char **argv)
shash_hashtable_t label_table; shash_hashtable_t label_table;
shash_init_hashtable(&label_table, LABEL_TABLE_SIZE); shash_init_hashtable(&label_table, LABEL_TABLE_SIZE);
build_label_table((char (*)[MAX_TOKEN_SIZE]) label_tokens.buffer, &label_table); build_label_table((char (*)[MAX_TOKEN_SIZE]) label_tokens.buffer, &label_table);
printf("Built label table\n");
dynamic_buffer_t no_label_definition_tokens; dynamic_buffer_t no_label_definition_tokens;
@ -155,7 +154,6 @@ int main(int argc, char **argv)
} }
remove_label_definition_tokens((char (*)[MAX_TOKEN_SIZE]) label_tokens.buffer, &no_label_definition_tokens); remove_label_definition_tokens((char (*)[MAX_TOKEN_SIZE]) label_tokens.buffer, &no_label_definition_tokens);
printf("Removed label defintions\n");
free(label_tokens.buffer); free(label_tokens.buffer);
// Check if the EIPA Assembly contains errors with the no_label_definition_tokens array // Check if the EIPA Assembly contains errors with the no_label_definition_tokens array
@ -171,7 +169,6 @@ int main(int argc, char **argv)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
replace_labels_with_adresses((char (*)[MAX_TOKEN_SIZE]) no_label_definition_tokens.buffer, &tokens, label_table, instruction_informations); replace_labels_with_adresses((char (*)[MAX_TOKEN_SIZE]) no_label_definition_tokens.buffer, &tokens, label_table, instruction_informations);
printf("Removed labels\n");
free(no_label_definition_tokens.buffer); free(no_label_definition_tokens.buffer);
// Generate the target code // Generate the target code
@ -206,6 +203,8 @@ int main(int argc, char **argv)
// Cleanup // Cleanup
destroy_instruction_information_hashtable(&instruction_informations); destroy_instruction_information_hashtable(&instruction_informations);
shash_destroy_hashtable(&label_table); shash_destroy_hashtable(&label_table);
free(target_code.buffer);
free(tokens.buffer);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }