> On 23 Sep 2016, at 19:41, Quinn The Eskimo! via swift-users
> wrote:
>
>
> On 23 Sep 2016, at 11:29, Gerriet M. Denkmann via swift-users
> wrote:
>
>> What about calloc then? Or use allocate and do a memset afterwards?
>
> For trivial data types (like UInt8) this will work, but if you wa
> On Sep 23, 2016, at 2:23 PM, Joe Groff wrote:
>
>
>> On Sep 23, 2016, at 2:20 PM, Jens Persson wrote:
>>
>> What is the difference between:
>> ptr.storeBytes(of: x, toByteOffset: offset, as: type(of: x))
>> ptr.advanced(by: offset).assumingMemoryBound(to: type(of: x)).pointee = x
>> ?
>> I
> On Sep 23, 2016, at 2:20 PM, Jens Persson wrote:
>
> What is the difference between:
> ptr.storeBytes(of: x, toByteOffset: offset, as: type(of: x))
> ptr.advanced(by: offset).assumingMemoryBound(to: type(of: x)).pointee = x
> ?
> I noticed that the former traps if storing to a misaligned offse
What is the difference between:
ptr.storeBytes(of: x, toByteOffset: offset, as: type(of: x))
ptr.advanced(by: offset).assumingMemoryBound(to: type(of: x)).pointee = x
?
I noticed that the former traps if storing to a misaligned offset while the
latter is happy to do that, and I saw it mentioned as
> On Sep 23, 2016, at 1:55 AM, Gerriet M. Denkmann via swift-users
> wrote:
>
>
>> On 23 Sep 2016, at 15:47, Gerriet M. Denkmann via swift-users
>> wrote:
>>
>> This used to work in Swift 2.2:
>>
>> var bitfield: UnsafeMutablePointer?
>> bitfield = UnsafeMutablePointer( malloc( 888 ) )
>>
> On 23 Sep 2016, at 15:47, Gerriet M. Denkmann via swift-users
> wrote:
>
> This used to work in Swift 2.2:
>
> var bitfield: UnsafeMutablePointer?
> bitfield = UnsafeMutablePointer( malloc( 888 ) )
>
> How is this written in Swift 3.0?
To answer my own question:
This works:
var bitfield: U
On 23 Sep 2016, at 11:29, Gerriet M. Denkmann via swift-users
wrote:
> What about calloc then? Or use allocate and do a memset afterwards?
For trivial data types (like UInt8) this will work, but if you want to follow
the rules I recommend reading the following:
* UnsafeRawPointer Migration
> On 23 Sep 2016, at 17:08, Svein Halvor Halvorsen via swift-users
> wrote:
>
> var bitfield: UnsafeMutablePointer?
> bitfield = UnsafeMutablePointer.allocate(capacity: 888)
>
Excellent!
I see that “- Postcondition: The pointee is allocated, but not initialized.”
What about calloc then? Or
var bitfield: UnsafeMutablePointer?
bitfield = UnsafeMutablePointer.allocate(capacity: 888)
> 23. sep. 2016 kl. 10.47 skrev Gerriet M. Denkmann via swift-users
> :
>
> This used to work in Swift 2.2:
>
> var bitfield: UnsafeMutablePointer?
> bitfield = UnsafeMutablePointer( malloc( 888 ) )
>
This used to work in Swift 2.2:
var bitfield: UnsafeMutablePointer?
bitfield = UnsafeMutablePointer( malloc( 888 ) )
How is this written in Swift 3.0?
Gerriet.
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo
10 matches
Mail list logo