aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authors-over-42023-06-21 17:36:09 -0400
committers-over-42023-06-21 17:36:09 -0400
commit8d85c8442ff15100eeb7262bf7ea37472fd78095 (patch)
tree8914aac38a212cbec00f15997bfdf19fdfa4d881 /src
parente7d1e397730c271ccb11ce547cd941d740f5a2fc (diff)
RETURN OGHF TEH BORKED SHIAT D: D: D:
Diffstat (limited to 'src')
-rw-r--r--src/lexer.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lexer.c b/src/lexer.c
index 731210e..6d9d5a8 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -121,9 +121,8 @@ token_t* lexer_collect(lexer_t* lexer, int (*end_char)(char), int fskip, int lsk
size_t len; // length of collected token so far
char* token; // collected token so far
- len = 1;
+ len = 0;
token = calloc(len, sizeof(char));
- token[0] = '\0';
if (fskip) { lexer_next(lexer); }
@@ -133,11 +132,11 @@ token_t* lexer_collect(lexer_t* lexer, int (*end_char)(char), int fskip, int lsk
current = lexer_get_c_as_string(lexer);
token = realloc(
token,
- (len + sizeof(char) * strlen(current))
+ (len + sizeof(current))
);
memcpy(token + len, current, sizeof(char) * strlen(current));
- len += sizeof(char) * strlen(current);
+ len += strlen(current) * sizeof(char);
lexer_next(lexer);
free(current);