Skip to content
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

Undefine allocation function for C extension class #126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stanhu
Copy link
Contributor

@stanhu stanhu commented Feb 3, 2025

Ruby 3.2 adds a new warning is printed when a Ruby class created in a C extension does not specify an allocate function or undefine it:

warning: undefining the allocator of T_DATA class FFI_Yajl::Ext::Encoder::YajlGen

As described in https://bugs.ruby-lang.org/issues/18007 and https://github.com/ruby/ruby/blob/7317f96727725ca37ddb06011918deb841de371c/doc/extension.rdoc#label-Write+the+C+Code, we only need to define an allocate function if the class uses a C struct and stores any values on it.

Closes #123

Description

[Please describe what this change achieves]

Issues Resolved

[List any existing issues this PR resolves, or any Discourse or
StackOverflow discussions that are relevant]

Check List

@stanhu stanhu requested review from a team as code owners February 3, 2025 21:20
@stanhu
Copy link
Contributor Author

stanhu commented Feb 3, 2025

@tpowell-progress Could you review this? This squashes an annoying warning showing up with Ruby 3.2 and up. 😄

Ruby 3.2 adds a new warning is printed when a Ruby class created in
a C extension does not specify an allocate function or undefine it:

```
warning: undefining the allocator of T_DATA class FFI_Yajl::Ext::Encoder::YajlGen
```

As described in https://bugs.ruby-lang.org/issues/18007 and
https://github.com/ruby/ruby/blob/7317f96727725ca37ddb06011918deb841de371c/doc/extension.rdoc#label-Write+the+C+Code,
we only need to define an allocate function if the class uses a C
struct and stores any values on it.

Closes chef#123

Signed-off-by: Stan Hu <[email protected]>
@stanhu stanhu force-pushed the sh-fix-ruby-t-data-warning branch from fe837bd to be9ee74 Compare February 3, 2025 21:24
@tpowell-progress
Copy link
Contributor

@stanhu I may have to request a rebase to fix tests. Opening a PR to drop 2.6 ⁉️

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.

warning: undefining the allocator of T_DATA class FFI_Yajl::Ext::Encoder::YajlGen
2 participants