> On Oct 3, 2016, at 10:20 AM, Jens Alfke via swift-users
> wrote:
>
>
>> On Oct 2, 2016, at 5:14 PM, Mike Ferenduros via swift-users
>> mailto:swift-users@swift.org>> wrote:
>>
>> Personally I would be surprised if the malloc caused an actual measurable
>> performance hit tbh.
>
> It won’
> On Oct 2, 2016, at 5:14 PM, Mike Ferenduros via swift-users
> wrote:
>
> Personally I would be surprised if the malloc caused an actual measurable
> performance hit tbh.
It won’t be noticeable against a call to SecRandom, as noted, but there are
other circumstances where it’s a big perform
Indeed,
But that function was just an example. I wanted to learn about how to use the
stack to call C functions that will fill some memory area passed as a pointer.
Jean-Denis
> On 3 Oct 2016, at 09:46, Quinn The Eskimo! via swift-users
> wrote:
>
>
> On 3 Oct 2016, at 01:14, Mike Ferendu
On 3 Oct 2016, at 01:14, Mike Ferenduros via swift-users
wrote:
> Personally I would be surprised if the malloc caused an actual measurable
> performance hit tbh.
Quite. SecRandom generates cryptographically sound random numbers and thus is
not optimised for speed.
Share and Enjoy
--
Quinn
on Sun Oct 02 2016, Mike Ferenduros wrote:
> You can use a local like this:
> var x: UInt32 = 0
> withUnsafePointer(to: x) { randomWordPT in
> //your existing code here
> }
>
> Or I'm not sure if small arrays go on the heap, but
They do.
> var bytes: [UInt8] = [0,0,0,0]
You can use a local like this:
var x: UInt32 = 0
withUnsafePointer(to: x) { randomWordPT in
//your existing code here
}
Or I'm not sure if small arrays go on the heap, but
var bytes: [UInt8] = [0,0,0,0]
_ = SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes)
on Sun Oct 02 2016, Jean-Denis Muys wrote:
> Hi,
>
> I have some issues using the new raw memory API. For instance, let's
> suppose I want to call the `SecRandomCopyBytes` API to generate a
> cryptographically secure random 32-bit number. The difficulty is its 3rd
> argument, which is declared a
Hi,
I have some issues using the new raw memory API. For instance, let's
suppose I want to call the `SecRandomCopyBytes` API to generate a
cryptographically secure random 32-bit number. The difficulty is its 3rd
argument, which is declared as UnsafeMutablePointer. Here is a
function that does that