No need to use malloc here, the buffer never gets large

This commit is contained in:
Lior Halphon 2020-05-07 22:46:06 +03:00
parent 8625b23c0d
commit e063671816
1 changed files with 2 additions and 7 deletions

View File

@ -23,7 +23,7 @@ int main()
size--;
}
uint8_t *literals = NULL;
uint8_t literals[8];
size_t literals_size = 0;
unsigned bits = 0;
unsigned control = 0;
@ -67,8 +67,7 @@ int main()
}
}
if (!found) {
literals = realloc(literals, ++literals_size);
literals[literals_size - 1] = byte;
literals[literals_size++] = byte;
}
}
@ -87,9 +86,5 @@ int main()
uint8_t end_byte = 1;
write(STDOUT_FILENO, &end_byte, 1);
if (literals) {
free(literals);
}
return 0;
}