Skip to content

Add JS_FreezeArrayBuffer - #1350

Merged
bnoordhuis merged 2 commits into
quickjs-ng:masterfrom
bnoordhuis:fix1347
Feb 15, 2026
Merged

bnoordhuis merged 2 commits into
quickjs-ng:masterfrom
bnoordhuis:fix1347

Conversation

@bnoordhuis

Copy link
Copy Markdown
Contributor

Fixes: #1347


Name TBD. JS_FixArrayBuffer? Freeze suggests it works like Object.freeze.

@saghul saghul left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@bnoordhuis

Copy link
Copy Markdown
Contributor Author

Thoughts on the name? I don't really like JS_FreezeArrayBuffer but I couldn't come up with anything better.

@saghul

saghul commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Thoughts on the name? I don't really like JS_FreezeArrayBuffer but I couldn't come up with anything better.

JS_SetArrayBufferImmutable? Note I just remember that I probably need a getter too, in order not to reset it, it it was already immutable, so this would give us a Get/Set symmetry.

@sepehrst

Copy link
Copy Markdown

If this is intended to be a one-way operation, I wonder if JS_ConstifyArrayBuffer communicates the intent more clearly? If it's meant to be reversible (as the bool immutable parameter suggests), then something like JS_LockArrayBuffer / JS_UnlockArrayBuffer might also work

@saghul

saghul commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Yes, it's meant to be reversible. The idea is to freeze / lock it when you need it in C and release it after you're done with the content.

@bnoordhuis

Copy link
Copy Markdown
Contributor Author

Renamed to JS_SetImmutableArrayBuffer, added JS_IsImmutableArrayBuffer. PTAL.

@saghul

saghul commented Feb 15, 2026

Copy link
Copy Markdown
Contributor

Perfect!

@bnoordhuis
bnoordhuis merged commit 0ee94cd into quickjs-ng:master Feb 15, 2026
122 checks passed
@bnoordhuis
bnoordhuis deleted the fix1347 branch February 15, 2026 22:14
rkd77 pushed a commit to rkd77/quickjs that referenced this pull request Feb 16, 2026
mochaaP pushed a commit to mcha-forks/quickjs that referenced this pull request May 20, 2026
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.

C API for locking array buffers?

3 participants