memcpy in Swift
memcpy in Swift
- Subject: memcpy in Swift
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Fri, 04 Jul 2014 17:00:23 +0700
Trying to convert this Objective-C code:
#define CHUNK_TYPE uint32_t
CHUNK_TYPE *bitField = calloc( bitFieldSizeInChunks, sizeof(CHUNK_TYPE) );
CHUNK_TYPE tempChunks[ ppp + 1 ];
memset( tempChunks, 0, sizeof( CHUNK_TYPE ) * ppp );
... fill tempChunks
memcpy( bitField + 1, tempChunks + 1, end * sizeof(CHUNK_TYPE) );
to Swift as:
typealias CHUNK_TYPE = UInt32
var bitField : UnsafePointer<CHUNK_TYPE> = UnsafePointer<CHUNK_TYPE>(0)
let bitFieldPointer = calloc( bitFieldSizeInChunks, sizeof( CHUNK_TYPE ) )
bitField = UnsafePointer<CHUNK_TYPE>(bitFieldPointer)
let tempChunks = CHUNK_TYPE[](count: Int(ppp + 1), repeatedValue: 0)
... fill tempChunks
but I cannot get this to work:
memcpy( bitField + 1, tempChunks + 1, end * sizeof(CHUNK_TYPE) );
Gerriet.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden