-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recompression #824
base: recompression
Are you sure you want to change the base?
Recompression #824
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few random comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments that seem to coalesce to a few categories:
- Style nits
- Out-of-bound checks - you need to make sure that all your array reads and writes are done within bounds, even if e.g. the input to the program is invalid (e.g. an attacker sends a corrupted brotli file), or, to a lesser extent, if the input to a function is invalid (e.g. a future programmer calls it with the wrong values). The former case needs to be handled gracefully, without crashing. The latter case, needs to be assert() against, at the very least. If this requires work that goes beyond the prototype's scope, leave a TODO to make sure this happens before the code's productization.
- Magic numbers - they make it hard to read the code and understand what it means. Constants with descriptive names are better
- Prototype-level shortcuts - No need to fix those IMO, but you do need to call them out (e.g. overly large allocations)
Also, I see a bunch of allocations but no free()
to go along with them...
const uint8_t* word = &words->data[offset]; | ||
const BrotliTransforms* transforms = BrotliGetTransforms(); | ||
/* String can be sometimes longer then copy_len */ | ||
uint8_t* string = (uint8_t*)malloc(sizeof(uint8_t) * copy_len * EXCEED_COPY_LEN_RATE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid warnings, you should add
#include <stdlib.h>
at the top of the file
Faster and more efficient recompression using previous compression artifacts such as backward references and block splits.