---
title: "CFDataSetLength(_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfdatasetlength(_:_:)"
---

# CFDataSetLength(_:_:)

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

## Declaration

```swift
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

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.

## See Also

### Modifying a Mutable Data Object

- [CFDataAppendBytes(_:_:_:)](corefoundation/cfdataappendbytes(_:_:_:).md)
- [CFDataDeleteBytes(_:_:)](corefoundation/cfdatadeletebytes(_:_:).md)
- [CFDataReplaceBytes(_:_:_:_:)](corefoundation/cfdatareplacebytes(_:_:_:_:).md)
- [CFDataIncreaseLength(_:_:)](corefoundation/cfdataincreaselength(_:_:).md)
