<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFDataSetLength(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFDataSetLength"
  },
  "title" : "CFDataSetLength(_:_:)"
}
-->

# CFDataSetLength(_:_:)

Resets the length of a CFMutableData object’s internal byte buffer.

```
func CFDataSetLength(_ theData: CFMutableData!, _ length: CFIndex)
```

## Parameters

`theData`

A CFMutableData object. If you pass an immutable CFData object, the behavior is not defined.

`length`

The new size of `theData`’s byte buffer.

## Discussion

This function resets the length of a CFMutableData object’s underlying byte buffer to a new size. If that size is less than the current size, it truncates the excess bytes. If that size is greater than the current size, it zero-fills the extension to the byte 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)