Skip to content

Commit 3b053e0

Browse files
3405691582dana
authored andcommitted
ManagedBuffer.capacity is unavailable on OpenBSD.
`.capacity` is backed by malloc introspection (`malloc_size`), which is not available on all platforms. The workaround is straightforward here, thankfully: instead, use the minimum capacity already specified.
1 parent 90702d6 commit 3b053e0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/System/Internals/RawBuffer.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ extension _RawBuffer {
8080
internal static func create(minimumCapacity: Int) -> Storage {
8181
Storage.create(
8282
minimumCapacity: minimumCapacity,
83-
makingHeaderWith: { $0.capacity }
83+
makingHeaderWith: {
84+
#if os(OpenBSD)
85+
minimumCapacity
86+
#else
87+
$0.capacity
88+
#endif
89+
}
8490
) as! Storage
8591
}
8692
}

0 commit comments

Comments
 (0)