summaryrefslogtreecommitdiff
path: root/src/pipac.c
diff options
context:
space:
mode:
authorJohnny Richard <johnny@johnnyrichard.com>2023-04-16 03:29:02 +0200
committerJohnny Richard <johnny@johnnyrichard.com>2023-04-16 03:29:02 +0200
commitd951985665bf3e0248286a30c67c28f505eb27c9 (patch)
treed8c77d73366d8a3eeb94f11163edc23201fff5c0 /src/pipac.c
parentd55938b34d6b7ee2c2d7da8483aaed5c8b9078a0 (diff)
Start using string_view on lexer and parser
This change fixes the memory leak when token got created. Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
Diffstat (limited to 'src/pipac.c')
-rw-r--r--src/pipac.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/pipac.c b/src/pipac.c
index 993d56d..6e6df9e 100644
--- a/src/pipac.c
+++ b/src/pipac.c
@@ -20,11 +20,12 @@
#include "lexer.h"
#include "parser.h"
+#include "string_view.h"
void
generate_gas_x86_64_linux(ast_function_t *func)
{
- if (strcmp(func->name, "main") != 0) {
+ if (!string_view_eq(func->name, string_view_from_str("main"))) {
fprintf(stderr, "[ERROR]: no main function has been defined!\n");
exit(EXIT_FAILURE);
}
@@ -47,7 +48,7 @@ void
print_tokens(lexer_t *lexer) {
token_t token;
for (lexer_next_token(lexer, &token); token.kind != TOKEN_EOF; lexer_next_token(lexer, &token)) {
- printf("%s:%d:%d: [kind=%d, value='%s']\n", lexer->filepath, token.row + 1, token.col + 1, token.kind, token.value);
+ printf("%s:%d:%d: [kind=%d, value='"SVFMT"']\n", lexer->filepath, token.row + 1, token.col + 1, token.kind, SVARG(&token.value));
}
}