Skip to content

Release resources before returning#4401

Merged
Cyan4973 merged 1 commit into
facebook:devfrom
mugitya03:MLK-1
Jun 4, 2025
Merged

Release resources before returning#4401
Cyan4973 merged 1 commit into
facebook:devfrom
mugitya03:MLK-1

Conversation

@mugitya03

Copy link
Copy Markdown

In main, resources were freed on the success path but not in the error path. This change ensures all allocated resources are released before returning.

In main, resources were freed on the success path but not in the error path.
This change ensures all allocated resources are released before returning.

@Cyan4973 Cyan4973 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I understand that it's considered "proper" to clean all resources on exiting the function.
To be fair, since it's main(), it's leaving program execution immediately on return(). Hence all resources are going to be released anyway. So the benefit seems moot.

That being said, the complexity introduced is also quite low, so it's a reasonable trade off.

@Cyan4973
Cyan4973 merged commit bd89405 into facebook:dev Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants