I am writing a tutorial and creating a wrapper on streaming compression.  In 
the code, I setup the stream source pointer: (input is of type Data)

  // set up the stream with the input source
  input.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) in
    stream.src_ptr = bytes
  }
  stream.src_size = input.count

Input is guaranteed to be alive for the entire lifetime of the stream.  
Everything seems to work fine but I thought I remember reading somewhere that 
it is bad form to let the bytes escape out of the withUnsafeBytes closure.  
Anyone know if I'm I dipping into undefined behavior here?

Thanks in advanced,
Ray

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to