Skip to content

Make pointer size consistent between backends #183

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
Apr 22, 2025

Conversation

ankane
Copy link
Contributor

@ankane ankane commented Apr 22, 2025

This PR makes the pointer size consistent between backends. Follow up to #179.

require "fiddle"

ptr = Fiddle::Pointer.new(0)
p ptr.size
p ptr.ref.size

ptr = Fiddle::Pointer["hello world"]
ptr.size = 0
p ptr.to_s
p ptr.to_str

JRuby + TruffleRuby before

9223372036854775807
8
""
""

CRuby + JRuby + TruffleRuby after

0
0
"hello world"
""

@kou kou merged commit 8eab55b into ruby:master Apr 22, 2025
62 of 66 checks passed
@kou
Copy link
Member

kou commented Apr 22, 2025

Thanks.

@ankane
Copy link
Contributor Author

ankane commented Apr 22, 2025

Thank you

Comment on lines +100 to +101
ptr.size = 0
assert_equal "hello", ptr.to_s
Copy link
Member

Choose a reason for hiding this comment

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

Looking at this this, why does ptr.size = 0 have no effect here, but it has on ptr.to_str in the previous test?
Shouldn't ptr.size = 0 change the @size of ptr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the current behavior of CRuby, so the PR mirrors it.

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.

3 participants