Skip to content

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Dec 29, 2025

This pull request reverts #885 which caused memory issues in WebAssembly by always allocating arrays, even when NULL was passed.

The hb_array_size() function safely returns 0 for NULL arrays, eliminating the need for allocating arrays for all AST Nodes. This was causing the "Cannot enlarge memory" errors in WASM builds, as seen in #1016.

This pull request brings back hb_array_size() in places where we previously accessed array->size directly. With that, we don't need to allocate array_init(8) just so we can assume we always have a size.

The problem is, even if we would use array_init(0) it would allocate memory that we are not going to need. So for now, I think it's better to be avoid allocating arrays and use hb_array_size() until we have fully integrated the new array implementation from #782. (/cc @timkaechele).

I also added a hb_narray_size() for API consistency that should help with the future array migration.

Resolves #1016
(Might also resolve #993)

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 29, 2025

npx https://pkg.pr.new/@herb-tools/formatter@1025
npx https://pkg.pr.new/@herb-tools/language-server@1025
npx https://pkg.pr.new/@herb-tools/linter@1025

commit: c4d43e4

@github-actions
Copy link

github-actions bot commented Dec 29, 2025

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit c4d43e4


✅ Preview deployment has been cleaned up.

@marcoroth marcoroth merged commit ccd15b1 into main Dec 29, 2025
32 checks passed
@marcoroth marcoroth deleted the lazy-array-initialization branch December 29, 2025 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linter: Cannot enlarge memory error

2 participants