Skip to content

Fix memory leaks #94

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RossComputerGuy
Copy link

Fixes #93

@@ -177,6 +177,7 @@ fn parseStruct(self: Yaml, arena: Allocator, comptime T: type, map: Map) Error!T
inline for (struct_info.fields) |field| {
var value: ?Value = map.get(field.name) orelse blk: {
const field_name = try mem.replaceOwned(u8, arena, field.name, "_", "-");
defer arena.free(field_name);
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, this looks sus to me. Why would we need to specifically free field_name if it's allocated in an arena and hence should be freed upon freeing the entire arena.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure but if you look at the error, you'll see that GPA does complain.

Copy link
Owner

Choose a reason for hiding this comment

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

When reporting the issue, did you use an arena, or did you pass a GPA instead?

Copy link
Author

Choose a reason for hiding this comment

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

A GPA

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.

Memory leak with struct
2 participants