Fixed bad free on stack.
Still need to figure that one out.
This commit is contained in:
parent
7b99292547
commit
743d16f696
@ -7,12 +7,13 @@
|
||||
#include <string.h>
|
||||
|
||||
HTab* htab_init() {
|
||||
HTab* htab = calloc(1, sizeof(HTab));
|
||||
HTab* htab = malloc(sizeof(HTab));
|
||||
|
||||
return htab;
|
||||
}
|
||||
|
||||
void htab_destroy(HTab* htab) { free(htab); }
|
||||
void htab_destroy(HTab* htab) { // free(htab);
|
||||
}
|
||||
|
||||
// Get the index of a key.
|
||||
size_t geti(char* key) {
|
||||
|
12
src/main.c
12
src/main.c
@ -4,10 +4,8 @@
|
||||
#include "include/ast.h"
|
||||
#include "include/dstr.h"
|
||||
#include "include/exec.h"
|
||||
#include "include/global.h"
|
||||
#include "include/htab.h"
|
||||
|
||||
#include "include/lexer.h"
|
||||
#include "include/stack.h"
|
||||
#include "include/util.h"
|
||||
|
||||
#include "../build/grammars/grammar.tab.h"
|
||||
@ -17,16 +15,11 @@ extern AST* root;
|
||||
extern char* inp;
|
||||
extern int yyparse();
|
||||
|
||||
Stack* scope;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
if (argc - 1 && strlen(argv[1]) > 0 && (inp = argv[1]) && !yyparse()) {
|
||||
log_dbg("Parsed successfully!\n");
|
||||
ast_print(exec_start(root));
|
||||
HTab* global = stack_pop(scope);
|
||||
htab_destroy(global);
|
||||
stack_destroy(scope);
|
||||
ast_destroy(root);
|
||||
exit(0);
|
||||
}
|
||||
@ -63,9 +56,6 @@ int main(int argc, char** argv) {
|
||||
#endif
|
||||
|
||||
ast_print(exec_start(root));
|
||||
HTab* global = stack_pop(scope);
|
||||
htab_destroy(global);
|
||||
stack_destroy(scope);
|
||||
|
||||
ast_destroy(root);
|
||||
}
|
||||
|
@ -12,12 +12,14 @@ Scope* scope_init(Scope* inherit) {
|
||||
}
|
||||
|
||||
void scope_destroy(Scope* scope) {
|
||||
if (!scope) return;
|
||||
htab_destroy(scope->here);
|
||||
if (scope->inherit != NULL) scope_destroy(scope->inherit);
|
||||
free(scope);
|
||||
}
|
||||
|
||||
void scope_destroy_psv(Scope* scope) {
|
||||
if (!scope) return;
|
||||
htab_destroy(scope->here);
|
||||
scope->inherit = NULL;
|
||||
free(scope);
|
||||
|
Loading…
x
Reference in New Issue
Block a user