# Passing (possibly non-contiguous) array to a C API

**URL:** <https://forums.swift.org/t/passing-possibly-non-contiguous-array-to-a-c-api/21810>\
**Category:** Using Swift\
**Tags:** c-interop\
**Created:** [March 20, 2019, 6:08am UTC](https://forums.swift.org/t/passing-possibly-non-contiguous-array-to-a-c-api/21810 "2019-03-20T06:08:57Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [March 20, 2019, 3:53pm UTC](https://forums.swift.org/t/passing-possibly-non-contiguous-array-to-a-c-api/21810/4 "2019-03-20T15:53:32Z")

</div>

Can confirm: even if the precise implementation changes, the array will always be forced into a contiguous form before being turned into a pointer; if it's being done so immutably, this may require a copy that gets thrown away.

(There _is_ a scenario in which this is a performance concern, [the same way as it can be for Strings](https://forums.swift.org/t/se-0247-contiguous-strings/21483)! But it's a lot less likely to come up in practice. Still, maybe we'll want contiguity detection for Array at some point too.)

---

_[View the full topic](https://forums.swift.org/t/passing-possibly-non-contiguous-array-to-a-c-api/21810)._
