-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Update ei_x_encode_long documentation to indicate variable length encoding. #8138
Conversation
CT Test ResultsTests are running... https://github.com/erlang/otp/actions/runs/7935778611 Results for commit 463f918 To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
Thanks for the PR! I think this note would be better in the module description, as it makes it clearer that we don't promise that any of these functions encode to a fixed length. |
Thanks! That makes sense, will make that change. |
[`ei_x_buff`](ei.md#ei_x_buff). The `ei_x_` encode functions do not guarantee | ||
the final buffer length, expect variable length buffers. |
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.
I think belongs more in the paragraph above. How about something like?
All encode functions assume that the `buf` and `index` parameters point to a
buffer large enough for the data. Note that the binary term format uses variable-
length encoding so different values can require a different amount of space. For
example, smaller integer values can be more compact than larger ones. To get
the size of an encoded term, without encoding it, pass `NULL` instead of a
buffer pointer. Parameter `index` is incremented, but nothing will be encoded.
This is the way in `ei` to "preflight" term encoding.
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.
I think it is much more clear. I didn't want to include the integer example directly incase it changes in the future but it is a good example. Will make this change.
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.
Great, I think the bit about "The ei_x_
encode functions do not guarantee
the final buffer length, expect variable length buffers." is a bit redundant given the paragraph above. Please remove that and squash the commits, and then I'll merge this straight away. :-)
Merged, thanks again for the PR! |
The
ei_x_encode_long
function does not encode the passed value to the fixed length of a long. Updating the documentation to make that more obvious.