10000 Add zlib:compress/1 by jgonet · Pull Request #1570 · atomvm/AtomVM · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 2 commits into from
Jun 19, 2025
Merged

Add zlib:compress/1 #1570

merged 2 commits into from
Jun 19, 2025

Conversation

jgonet
Copy link
Contributor
@jgonet jgonet commented Mar 14, 2025

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

@jgonet jgonet force-pushed the jgonet/zlib-compress branch from 0a8ee68 to 55d0eaf Compare March 14, 2025 00:26
@jgonet jgonet mentioned this pull request Mar 13, 2025
36 tasks
Copy link
Collaborator
@bettio bettio left a 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.

@@ -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)
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@jgonet jgonet force-pushed the jgonet/zlib-compress branch from 55d0eaf to 602637e Compare June 11, 2025 09:44
TheSobkiewicz and others added 2 commits June 19, 2025 19:27
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>
@jgonet jgonet force-pushed the jgonet/zlib-compress branch from dbd7c37 to b7745b4 Compare June 19, 2025 17:28
@bettio bettio merged commit eecfae9 into atomvm:main Jun 19, 2025
189 of 241 checks passed
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

Successfully merging this pull request may close these issues.

iolist_size/1 and iolist_to_binary/1 should badarg with lists of unicode characters
3 participants
0