-
-
Notifications
You must be signed in to change notification settings - Fork 73
C: New hb_array implementation
#782
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
Conversation
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
539a8bf to
38000ec
Compare
marcoroth
reviewed
Nov 5, 2025
marcoroth
reviewed
Nov 5, 2025
Owner
|
I'm curious where you think this would come in handy. I think the problem is, at least for the AST Nodes, that they don't share the same item size, unless you have an array of a specific AST Node type. |
df0d5d8 to
879120e
Compare
2b3ddaf to
6d903e3
Compare
014444e to
3cd7856
Compare
2ac4ca6 to
75c0651
Compare
75c0651 to
4c4e969
Compare
marcoroth
approved these changes
Dec 25, 2025
Owner
marcoroth
left a comment
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.
Thank you @timkaechele! 🙏🏼
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
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 adds a new version of the
hb_arraycalledhb_narraythat implements an array that can actually hold the elements it stores.The existing
hb_arrayonly allows to store pointers to heap allocated elements, the newhb_narrayacts as a container that also provides the backing memory for the elements it holds.It's important to note that you can still make the elements pointers if you want to.
Why?
Next steps
hb_arrayusageshb_arrayand renamehb_narraytohb_arrayMemory layout