Skip to content

[Embedded] Mark ManagedBuffer.capacity as unavailable - #91407

Open
Azoy wants to merge 4 commits into
swiftlang:mainfrom
Azoy:embedded-managedbuffer
Open

[Embedded] Mark ManagedBuffer.capacity as unavailable#91407
Azoy wants to merge 4 commits into
swiftlang:mainfrom
Azoy:embedded-managedbuffer

Conversation

@Azoy

@Azoy Azoy commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This removes the malloc_size reference from embedded (which might not exist on some platforms) by making this API unavailable entirely. Clients should store their own reference to the allocated capacity instead.

Resolves: rdar://184234583

@Azoy
Azoy marked this pull request as ready for review August 11, 2026 22:06
@Azoy
Azoy requested a review from a team as a code owner August 11, 2026 22:06
@Azoy

Azoy commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci please smoke test

@Azoy

Azoy commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci please smoke test

@lorentey lorentey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The capacity is typically also stored in the header; allocating a full extra word on storing it for a marginal benefit is quite wasteful, especially on embedded platforms.

On platforms where malloc_size isn't available (like OpenBSD), we simply make var capacity unavailable. There is no reason we should not do the exact same thing here.

@Azoy Azoy changed the title [Embedded] Store capacity in ManagedBuffer for embedded [Embedded] Mark ManagedBuffer.capacity as unavailable Aug 12, 2026
@Azoy

Azoy commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@swift-ci please smoke test

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