C: Deprecate hb_array_size#885
Merged
Merged
Conversation
0f5326a to
040628d
Compare
marcoroth
reviewed
Nov 16, 2025
marcoroth
left a comment
Owner
There was a problem hiding this comment.
Is there a reason why we don't remove hb_array_size with this right away?
040628d to
de27870
Compare
Contributor
Author
|
It’s going to be dropped as part of the migration to the new array implementation. |
de27870 to
719d516
Compare
719d516 to
8fd61ff
Compare
marcoroth
added a commit
that referenced
this pull request
Dec 29, 2025
…ge (#1025) 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR deprecates the
hb_array_sizefunction in favor of directly accessinghb_array_T.sizeAs part of the deprecation, ast nodes now always have fully initialized array members.