On Sat, May 21, 2016 at 2:15 AM, Adrian Zubarev via swift-users <swift-users@swift.org> wrote: > So basically if I do something like this I should be on the safe side:
Yes, this code is safe. If you just want to store a contiguous buffer of elements of the same type, you should consider using Array. It has methods that will allow you to operate on the unsafe pointer to the memory if you need that for speed, but it will do the memory management for you. > Does the UnsafeMutablePointer reserves me a safe portion of memory (by safe > I mean which isn’t used by anyone at the time I will start using it)? Yes, you will become a unique owner of the newly allocated chunk of memory. (Same as malloc() in C.) Dmitri -- main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if (j){printf("%d\n",i);}}} /*Dmitri Gribenko <griboz...@gmail.com>*/ _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users