implements len flag

This commit is contained in:
SuperNovaa41 2025-02-06 22:41:08 -05:00
parent 20b24245d6
commit 3919140cf8

View File

@ -25,6 +25,7 @@ int main(int argc, char* argv[])
FILE* stream; FILE* stream;
bool outfile; bool outfile;
int hex_lines, i; int hex_lines, i;
size_t filesize;
init_flags(&flags); init_flags(&flags);
@ -43,7 +44,10 @@ int main(int argc, char* argv[])
read_file_to_buf(argv[1], &file_content); read_file_to_buf(argv[1], &file_content);
hex_lines = get_hex_lines(strlen(file_content));
filesize = (flags.len == -1) ? strlen(file_content) : flags.len;
hex_lines = get_hex_lines(filesize);
hex_chunk_t* lines = malloc(sizeof(hex_chunk_t) * hex_lines); hex_chunk_t* lines = malloc(sizeof(hex_chunk_t) * hex_lines);