• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
memcpy in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: NSByteCountFormatter in Swift
  • Next by Date: Re: Framework linking error
  • Previous by thread: Re: NSByteCountFormatter in Swift
  • Next by thread: Questions about Xcode Continuous Integration
  • Index(es):
    • Date
    • Thread