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

Remove dead code in oj_hash_init #873

Merged
merged 2 commits into from
Apr 6, 2023

Conversation

peterzhu2118
Copy link
Contributor

No description provided.

We don't need to use rb_gc_register_address since cache_class is
allocated on the stack.
@ohler55
Copy link
Owner

ohler55 commented Apr 6, 2023

I believe classes can move hence the need for the registration.

@peterzhu2118
Copy link
Contributor Author

rb_gc_register_address takes a pointer to a VALUE, but cache_class is allocated on the stack which means that it becomes invalid memory the moment the function returns. You can see the implementation here.

This function doesn't seem to be using cache_class in any way that is unsafe for compaction, so we don't need to pin it (i.e. tell compaction that this object cannot move).

@ohler55
Copy link
Owner

ohler55 commented Apr 6, 2023

You are correct. Thanks.

@ohler55 ohler55 merged commit 5dd6f03 into ohler55:develop Apr 6, 2023
36 checks passed
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.

None yet

2 participants