Correct way to call “realloc” in Swift with a Float array?
问题 I'm trying figure out what size to send "realloc" when I call it through Swift. It seems that I have to add an extra byte , but I don't understand why. typealias Floats = UnsafeMutablePointer<Float> let FLOAT_SIZE = sizeof( Float ) func floats_realloc( floats:Floats, qty_of_floats:Int ) -> Floats { let KLUDGE = 1 // Why? let qty_of_bytes = ( qty_of_floats * FLOAT_SIZE ) + KLUDGE let realloced_floats = Floats( realloc( floats, UInt( qty_of_bytes ) ) ) return realloced_floats } If I set KLUDGE