<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Compression",
  "identifier" : "/documentation/Compression/compression_decode_buffer(_:_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Compression"
    ],
    "preciseIdentifier" : "c:@F@compression_decode_buffer"
  },
  "title" : "compression_decode_buffer(_:_:_:_:_:_:)"
}
-->

# compression_decode_buffer(_:_:_:_:_:_:)

Decompresses the contents of a source buffer into a destination buffer.

```
func compression_decode_buffer(_ dst_buffer: UnsafeMutablePointer<UInt8>, _ dst_size: Int, _ src_buffer: UnsafePointer<UInt8>, _ src_size: Int, _ scratch_buffer: UnsafeMutableRawPointer?, _ algorithm: compression_algorithm) -> Int
```

## Parameters

`dst_buffer`

Pointer to the buffer that receives the decompressed data.

`dst_size`

Size of the destination buffer in bytes.

`src_buffer`

Pointer to a buffer containing all of the compressed source data.

`src_size`

Size of the data in the source buffer in bytes.

`scratch_buffer`

If `scratch_buffer` is not `nil`, this parameter is a pointer to a buffer that the function uses for scratch purposes. The size of this buffer must be at least the size returned by a previous call to [`compression_decode_scratch_buffer_size(_:)`](/documentation/Compression/compression_decode_scratch_buffer_size(_:)).

    If     `scratch_buffer`     is     `nil`    , the function creates and manages its own scratch space, but with a possible performance hit.

`algorithm`

A constant of type [`compression_algorithm`](/documentation/Compression/compression_algorithm) that specifies the compression algorithm.

## Return Value

The number of bytes written to the destination buffer after decompressing the input.  If there is not enough space in the destination buffer to hold the entire decompressed output, the function writes the first `dst_size` bytes to the buffer and returns `dst_size`. Note that this behavior differs from that of [`compression_encode_buffer(_:_:_:_:_:_:)`](/documentation/Compression/compression_encode_buffer(_:_:_:_:_:_:)).

## Discussion

The function writes the decompressed data to `dst_buffer`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)