Skip to content
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

Regarding uint8_t in node header definition #69

Open
Ahacad opened this issue May 7, 2021 · 1 comment
Open

Regarding uint8_t in node header definition #69

Ahacad opened this issue May 7, 2021 · 1 comment

Comments

@Ahacad
Copy link

Ahacad commented May 7, 2021

Hello, I'm still a learner of the c programming language and database. The below line has uint8_t but the definitions above it are all uint32_t, I think they should use the same def, all uint8_t or all uint32_t, is there any detail here I didn't notice?

const uint8_t COMMON_NODE_HEADER_SIZE =

@nettybun
Copy link

nettybun commented May 8, 2021

It's a matter of opinion in code and some people want to use the smallest datatype necessary. Possibly because it conveys some information to the reader that a header size won't be more than 255, whatever the number is.

This is more common in larger data structures. Say you have an absolute binary offset: you'll probably store it as a uint_64 to be safe (able to store offsets into several GBs) - meanwhile a magic header (like PNG) will be uint_8 since it's only a few bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants