Skip to content

Conversation

ankane
Copy link
Contributor

@ankane ankane commented Apr 19, 2025

p Fiddle::Pointer.new(1)

CRuby

#<Fiddle::Pointer:0x0000600000983240 ptr=0x0000000000000001 size=0 free=0x0000000000000000>

JRuby before

#<Fiddle::Pointer ptr=1 size=9223372036854775807 free=nil>

JRuby after

#<Fiddle::Pointer ptr=0x0000000000000001 size=9223372036854775807 free=0x0000000000000000>

Note: size is incorrect for JRuby, which is not addressed with this PR

@ankane ankane force-pushed the ffi-backend-inspect branch from a4257ee to cb7c6ca Compare April 19, 2025 23:30
@kou kou merged commit 582f443 into ruby:master Apr 21, 2025
62 of 66 checks passed
@ankane
Copy link
Contributor Author

ankane commented Apr 21, 2025

Thanks @kou

kou added a commit that referenced this pull request Apr 22, 2025
This PR makes the pointer size consistent between backends. Follow up to
#179.

```ruby
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

```text
9223372036854775807
8
""
""
```

CRuby + JRuby + TruffleRuby after

```text
0
0
"hello world"
""
```

---------

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

2 participants