Re: [swift-users] Set size of byte array

2016-08-09 Thread Arnold Schwaighofer via swift-users
> On Aug 9, 2016, at 12:07 PM, Joe Groff wrote: > > >> On Aug 5, 2016, at 9:42 AM, KS Sreeram via swift-users >> wrote: >> >> >>> On 05-Aug-2016, at 1:19 PM, Daniel Vollmer wrote: >>> >>> I’m by no means a Swift expert (not even a user at the moment), but I don't >>> see a way to do this

Re: [swift-users] Set size of byte array

2016-08-09 Thread Joe Groff via swift-users
> On Aug 5, 2016, at 9:42 AM, KS Sreeram via swift-users > wrote: > > >> On 05-Aug-2016, at 1:19 PM, Daniel Vollmer wrote: >> >> I’m by no means a Swift expert (not even a user at the moment), but I don't >> see a way to do this either. The best that comes to mind is initializing a >> Contig

Re: [swift-users] Set size of byte array

2016-08-08 Thread Dave Abrahams via swift-users
on Fri Aug 05 2016, KS Sreeram wrote: >> On 05-Aug-2016, at 1:19 PM, Daniel Vollmer wrote: >> >> I’m by no means a Swift expert (not even a user at the moment), but I don't >> see a way to do this either. The best that comes to mind is initializing a >> ContiguousArray with the sufficient capa

Re: [swift-users] Set size of byte array

2016-08-05 Thread KS Sreeram via swift-users
> On 05-Aug-2016, at 4:02 PM, Brent Royal-Gordon wrote: > > I don't believe this is possible with an Array; the only way to work with > uninitialized memory is with an UnsafeMutablePointer. > > The simplest solution is probably to load the data into an allocated chunk of > memory with an Uns

Re: [swift-users] Set size of byte array

2016-08-05 Thread KS Sreeram via swift-users
> On 05-Aug-2016, at 1:19 PM, Daniel Vollmer wrote: > > I’m by no means a Swift expert (not even a user at the moment), but I don't > see a way to do this either. The best that comes to mind is initializing a > ContiguousArray with the sufficient capacity as size, using > withUnsafeBufferPointer

Re: [swift-users] Set size of byte array

2016-08-05 Thread Brent Royal-Gordon via swift-users
> On Aug 4, 2016, at 11:42 PM, KS Sreeram via swift-users > wrote: > > I’m trying to initialize a byte-array efficiently with minimal copying with > the following steps: > > 1. Create an empty byte array. > 2. Reserve sufficient capacity in the array. > 3. Use mutable pointers into the array t

[swift-users] Set size of byte array

2016-08-04 Thread KS Sreeram via swift-users
Hello I’m trying to initialize a byte-array efficiently with minimal copying with the following steps: 1. Create an empty byte array. 2. Reserve sufficient capacity in the array. 3. Use mutable pointers into the array to fill in the data. 4. The actual size that was filled is known only after it