Skip to content

[Macros/C bridging] Replace use of free for Swift-allocated pointer #68271

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

Merged
merged 2 commits into from
Sep 1, 2023

Conversation

DougGregor
Copy link
Member

We cannot depend on Swift's unsafe pointers using malloc under the hood, so don't use free on them. Instead, expose entry points from Swift to C++ to free any Swift-allocated data structures that need to be deallocated from C++.

We cannot depend on Swift's unsafe pointers using `malloc` under the
hood, so don't use `free` on them. Instead, expose entry points from
Swift to C++ to free any Swift-allocated data structures that need to
be deallocated from C++.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

Thanks @DougGregor!

Buyer beware: the `MallocAllocator` does not, in fact, use `malloc`, so
one cannot pair an allocation using `MallocAllocator` with an actual
`free`.
@DougGregor DougGregor changed the title [Macros] Replace use of free for Swift-allocated pointer [Macros/C bridging] Replace use of free for Swift-allocated pointer Sep 1, 2023
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit be82d0b into swiftlang:main Sep 1, 2023
@DougGregor DougGregor deleted the no-free-for-you branch September 1, 2023 21:37
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.

3 participants