-
Notifications
You must be signed in to change notification settings - Fork 120
Add zlib:compress/1 #1570
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
Add zlib:compress/1 #1570
Conversation
0a8ee68
to
55d0eaf
Compare
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 left some comments, in addition I think adding a module for typespecs might be a good addition.
src/libAtomVM/nifs.c
Outdated
@@ -2411,59 +2421,69 @@ static term nif_erlang_float_to_list(Context *ctx, int argc, term argv[]) | |||
return make_list_from_ascii_buf((uint8_t *) float_buf, len, ctx); | |||
} | |||
|
|||
static term nif_erlang_list_to_binary_1(Context *ctx, int argc, term argv[]) | |||
static term list_to_binary(term list, term *ret, Context *ctx) |
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.
If we want to keep this approach I really suggest renaming this function to something like: list_to_binary_maybe_gc
so the caller will be aware about the fact that after a call to this function, any non trivial term will be invalid.
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 moved only part of this function in the end. It doesn't alloc on erl-heap.
55d0eaf
to
602637e
Compare
https://www.erlang.org/doc/apps/erts/zlib.html#compress/1 Signed-off-by: Jakub Gonet <jakub.gonet@swmansion.com>
Code in folding functions casted avm_int_t to char, silently truncating input. Now we check if the value fits in the char and fail operation if not. Signed-off-by: Jakub Gonet <jakub.gonet@swmansion.com>
dbd7c37
to
b7745b4
Compare
https://www.erlang.org/doc/apps/erts/zlib.html#compress/1
Fixes #1632.
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later