Skip to content

Commit

Permalink
Update ei_encode_long documentation to indicate variable length encod…
Browse files Browse the repository at this point in the history
…ing.
  • Loading branch information
mpope9 committed Mar 4, 2024
1 parent 5d23e40 commit 2d32e91
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/erl_interface/doc/references/ei.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ All functions take two parameters:
The data is thus at `buf[*index]` when an `ei` function is called.

All encode functions assume that the `buf` and `index` parameters point to a
buffer large enough for the data. 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.
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 are also encode functions that use a dynamic buffer. It is often more
convenient to use these to encode data. All encode functions comes in two
Expand Down

0 comments on commit 2d32e91

Please sign in to comment.