In C I would do something like this
int count = 10;
int *buffer;
num = malloc(count * sizeof(int));
for (int i = 0; i < count; i++) {
buffer[i] = rand();
}
I have seen UnsafeMutablePointer used like this
let buffer = UnsafeMutablePointer<Int>.alloc(count)
for i in 0..<count {
buffer[i] = Int(arc4random())
}
How do I use UnsafeMutableBufferPointer for a C style buffer in Swift? Also, how would I realloc more space for the pointer?