---
title: "withContiguousMutableStorageIfAvailable(in:_:)"
framework: coremedia
role: symbol
role_heading: Instance Method
path: "coremedia/cmmutabledatablockbuffer/withcontiguousmutablestorageifavailable(in:_:)"
---

# withContiguousMutableStorageIfAvailable(in:_:)

Access contents of the buffer if available as contiguous memory block.

## Declaration

```swift
mutating func withContiguousMutableStorageIfAvailable<R>(in range: Range<Int>? = nil, _ body: (UnsafeMutableRawBufferPointer) throws -> sending R) rethrows -> sending R?
```

## Parameters

- `range`: Range of the buffer to access. Pass nil to access the whole buffer.
- `body`: Closure to execute with the memory block

## Discussion

Discussion This method calls body(buffer), where buffer is a pointer to the block buffers contiguous storage. If the contiguous storage doesn’t exist,  the method doesn’t call body — it immediately returns nil.
