feat: figure out valgrind!

This commit is contained in:
NunoSempere 2023-05-02 20:41:34 -04:00
parent 35650bc85d
commit e269917240
3 changed files with 11 additions and 4 deletions

View File

@ -6,8 +6,8 @@
# make uninstall
## C compiler
CC=tcc # much faster compilation than gcc
COMPILER_FLAGS=#-g3 -Wall -Wextra -Wconversion -Wdouble-promotion -Wno-unused-parameter -Wno-unused-function -Wno-sign-conversion -fsanitize=undefined
CC=gcc # much faster compilation than gcc
COMPILER_FLAGS=#-Wall -Wextra -Wconversion -Wdouble-promotion -Wno-unused-parameter -Wno-unused-function -Wno-sign-conversion -fsanitize=undefined # -g3
# exclude: -fsanitize-trap, because I'm using an old version of gcc and couldn't bother getting a new one.
## ^ from <https://nullprogram.com/blog/2023/04/29/>
## <https://news.ycombinator.com/item?id=35758898>
@ -35,8 +35,12 @@ STYLE_BLUEPRINT=webkit
FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
build: $(SRC)
$(CC) $(COMPILER_FLAGS) $(INCS) $(SRC) $(MPC) -o mumble $(LIBS)
$(CC) $(COMPILER_FLAGS) $(INCS) $(SRC) $(MPC) -o mumble $(LIBS) $(DEBUG)
format: $(SRC)
$(FORMATTER) $(SRC)
debug:
gcc -I/usr/include/editline ./src/mumble.c ./src/mpc/mpc.c -o mumble -lm -ledit -g
# valgrind --tool=memcheck --leak-check=yes --show-leak-kinds=all ./mumble
valgrind --tool=memcheck --leak-check=yes ./mumble

BIN
mumble

Binary file not shown.

View File

@ -815,6 +815,7 @@ lispval* evaluate_lispval(lispval* l, lispenv* env)
// builtin_functions(operation->sym, l, env);
delete_lispval(f);
delete_lispval(operands);
// delete_lispval(temp);
if(VERBOSE) printfln("Returning");
return answer;
}
@ -921,10 +922,12 @@ int main(int argc, char** argv)
delete_lispval(l);
// if(VERBOSE) printfln("Deleted that ^ lispval");
// ^ I do not understand how the memory in l is freed.
// delete the ast
mpc_ast_delete(ast);
} else {
/* Otherwise Print the Error */
mpc_err_print(result.error);
// mpc_err_delete(result.error);
mpc_err_delete(result.error);
}
add_history(input);
// can't add if input is NULL