[Capsule] Make alignment calculation robust

This commit is contained in:
Michael Steindorfer committed 2022-08-09 17:20:28 +02:00
1 parent d295c30459
commit 2856197785
1 file changed
+1 -1
+1 -1
View File
@@ -56,7 +56,7 @@ final class BitmapIndexedMapNode<Key, Value>: MapNode where Key: Hashable {
let memory = UnsafeMutableRawPointer.allocate(
byteCount: dataCapacityInBytes + trieCapacityInBytes,
alignment: 8)
alignment: Swift.max(MemoryLayout<DataBufferElement>.alignment, MemoryLayout<TrieBufferElement>.alignment))
let dataBaseAddress = memory.advanced(by: trieCapacityInBytes).bindMemory(to: DataBufferElement.self, capacity: dataCapacity)
let trieBaseAddress = memory.bindMemory(to: TrieBufferElement.self, capacity: trieCapacity)