calloc in Swift

前端 未结 3 1602
余生分开走
余生分开走 2021-01-13 17:10

How do I transform the following ObjectiveC statements into SWIFT:

UInt32 *pixels;
pixels = (UInt32 *) calloc(height * width, sizeof(UInt32));
3条回答
  •  鱼传尺愫
    2021-01-13 17:41

    For Swift-3 : UnsafeMutablePointer is replace by UnsafeMutableRawPointer

     var pixels = UnsafeMutableRawPointer( calloc(height * width, MemoryLayout.size) )
    

    Reference

提交回复
热议问题