Re: [swift-users] Unsafe(Mutable)Pointer (suc)predecessor and advancedBy functions

2016-05-26 Thread Austin Zheng via swift-users
This is where it gets tricky. When you create a chunk of memory using 'UnsafeMutablePointer.memory()' or 'alloc()', it's as if you are programming in C with 'malloc' and 'free'. The memory you create and the objects you put in that memory don't participate in ARC - the runtime will not track

Re: [swift-users] Unsafe(Mutable)Pointer (suc)predecessor and advancedBy functions

2016-05-26 Thread Adrian Zubarev via swift-users
It's also not clear sometimes exactly what "out of bounds" means - for example, you might have a big chunk of memory representing an array, and then you take a pointer to only part of that memory, representing a slice of the array. In this case you can write "out of bounds" of the slice, but

Re: [swift-users] Unsafe(Mutable)Pointer (suc)predecessor and advancedBy functions

2016-05-26 Thread Austin Zheng via swift-users
On Thu, May 26, 2016 at 10:31 AM, Adrian Zubarev via swift-users < swift-users@swift.org> wrote: > So theoretically I could build a wrapper type for Unsafe(Mutable)Pointer > which will be safe to use and never exceed the allocated range! > Yeah, if I remember correctly this is actually how the

Re: [swift-users] Unsafe(Mutable)Pointer (suc)predecessor and advancedBy functions

2016-05-26 Thread Adrian Zubarev via swift-users
So theoretically I could build a wrapper type for Unsafe(Mutable)Pointer which will be safe to use and never exceed the allocated range! public func successor() -> UnsafeMutablePointer? { // return `nil` if out of range } So why don’t we have safe pointers today? Any technical reasons

Re: [swift-users] Unsafe(Mutable)Pointer (suc)predecessor and advancedBy functions

2016-05-26 Thread Andrew Trick via swift-users
> On May 26, 2016, at 9:59 AM, Adrian Zubarev via swift-users > wrote: > > I’ve got one more questions about Unsafe(Mutable)Pointer. I know that I’m > able to access memory that might not belong to me. > > My question is: > > Can I trust these functions that they

[swift-users] String manipulation (replacingOccurrences) in Linux swift

2016-05-26 Thread Carlos Barrera Hernandez via swift-users
Hi, I’m currently using swift to build a project, and have found a pretty hard to bypass roadBlock. The main workflow of the project is - Read a csv file - Extract the values of the rows and columns - Process data extracted from file - Write some results to another file Pretty simple and