I have a C function in a file with name (Buffer is a C struct)
BufferInit(Buffer *buffer, int32_t size)
As I am moving to Swift, in my Swift class I declare a private var like
var buffer:Buffer?
and in init function I make a call like this
BufferInit(&buffer, 32)
But I get compilation errors, what is the correct way to achieve the same in Swift? I call call the same BufferInit from Objective-C without issues but Swift is messy.
EDIT: Here are details,
typedef struct {
void *buffer;
int32_t length;
int32_t tail;
int32_t head;
} Buffer;
Error is compiler is asking me to unwrap buffer and correct the code as(which I don't think is correct):
BufferInit(&buffer!, 32)
Bufferstruct?buffershould be initialized and not an optional.