Leaving Array's buffer uninitialised is breach of contract
valeriyvan opened this issue · comments
Discussion
Inside the closure, set the initializedCount
parameter to the number of elements that are initialized by the closure. The memory in the range buffer[0..<initializedCount]
must be initialized at the end of the closure’s execution, and the memory in the range buffer[initializedCount...]
must be uninitialized. This postcondition must hold even if the initializer closure throws an error.
this is only a breach-of-contract in the generic case; because UInt8
is a trivial type, it should be perfectly valid to leave the memory uninitialized. i am reluctant to have PNG.Data.Rectangular
be backed by a managed buffer or some sort because there are a lot of benefits to having it backed by a normal Array