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

cgen: add codegen for auto free methods for interface type #22555

Merged
merged 8 commits into from
Oct 21, 2024

Conversation

felipensp
Copy link
Member

Fix #22074

@felipensp felipensp changed the title cgen: fix auto free methods for interface type cgen: add codegen for auto free methods for interface type Oct 17, 2024
@felipensp felipensp marked this pull request as ready for review October 20, 2024 18:04
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Excellent work.

@@ -0,0 +1,7 @@
void main__IFoo_free(main__IFoo* it) {
if (it->_typ == _main__IFoo_main__Foo_index) { main__Foo_free(it->_main__Foo); return; }
Copy link
Member

@spytheman spytheman Oct 21, 2024

Choose a reason for hiding this comment

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

It could also generate it->_main__Foo = NULL; right after the free call, before the return.
That will make use after frees easier to detect, and simplify the work of the mark stage of the GC, if used in combination with -autofree.

@spytheman spytheman merged commit de46d9d into vlang:master Oct 21, 2024
78 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.

interface variable breaks -autofree
3 participants