Skip to content

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"
""

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
@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