caught some small mistakes in a later code review

This commit is contained in:
IoIxD 2026-01-19 19:21:13 -07:00
commit efe2bf1ba5
3 changed files with 11 additions and 5 deletions

View file

@ -40,7 +40,7 @@ void msh_lexer_push_item(msh_lexer *lexer, msh_lexer_item_type type, char *buf,
}; };
void msh_lexer_parse(msh_lexer *lexer, char *buf, SIZE_TYPE sz) { void msh_lexer_parse(msh_lexer *lexer, char *buf, SIZE_TYPE sz) {
int i = 0, n = 0, last = 0; int i = 0, n = 0, j = 0;
char *cur_word_buf = msh_callocate(1024, sizeof(char)); char *cur_word_buf = msh_callocate(1024, sizeof(char));
@ -91,11 +91,13 @@ void msh_lexer_parse(msh_lexer *lexer, char *buf, SIZE_TYPE sz) {
break; break;
} }
if (do_clear) { if (do_clear) {
msh_deallocate(cur_word_buf); for (j = 0; j < 1024; j++) {
cur_word_buf = msh_callocate(1024, sizeof(char)); cur_word_buf[j++] = 0;
}
n = 0; n = 0;
} }
} }
msh_deallocate(cur_word_buf);
} }
void msh_lexer_execute(msh_lexer *lexer) { void msh_lexer_execute(msh_lexer *lexer) {

View file

@ -99,7 +99,11 @@ msh_file *msh_file_open(const char *file) {
return f; return f;
}; };
void msh_file_close(msh_file *file) { SYSCALL(close, file->fd); }; void msh_file_close(msh_file *file) {
SYSCALL(close, file->fd);
msh_deallocate(file);
};
void msh_file_read(msh_file *file, char *ptr, SIZE_TYPE n) { void msh_file_read(msh_file *file, char *ptr, SIZE_TYPE n) {
SYSCALL(read, file->fd, ptr, n); SYSCALL(read, file->fd, ptr, n);

View file

@ -41,10 +41,10 @@ void msh_str_copy_strs(char *dst, ...) {
} }
n += i; n += i;
} }
va_end(va);
}; };
void msh_str_copy_str(char *dst, char *src) { void msh_str_copy_str(char *dst, char *src) {
while ((*dst++ = *src++)) while ((*dst++ = *src++))
; ;
*dst++ = '\0';
}; };