---
title: withBytes
framework: kernel
role: symbol
role_heading: Type Method
path: kernel/iobuffermemorydescriptor/1574834-withbytes
---

# withBytes

Creates a buffer memory descriptor and fills it with the specified bytes.

## Declaration

```occ
static OSPtr<IOBufferMemoryDescriptor> withBytes(const void *bytes, vm_size_t withLength, IODirection withDirection, bool withContiguousMemory);
```

## Parameters

- `bytes`: The bytes to copy into the newly allocated buffer.
- `withLength`: The number of bytes in the bytes parameter.
- `withDirection`: The direction of the I/O transfer. For example: kIODirectionOut, kIODirectionIn.
- `withContiguousMemory`: A Boolean value that indicates whether to use a contiguous block of memory for the descriptor’s buffer.

## See Also

### Creating a Memory Buffer Descriptor

- [inTaskWithOptions](kernel/iobuffermemorydescriptor/1813824-intaskwithoptions.md)
- [inTaskWithOptions](kernel/iobuffermemorydescriptor/1574847-intaskwithoptions.md)
- [inTaskWithOptions](kernel/iobuffermemorydescriptor/3516446-intaskwithoptions.md)
- [inTaskWithPhysicalMask](kernel/iobuffermemorydescriptor/1813825-intaskwithphysicalmask.md)
- [inTaskWithPhysicalMask](kernel/iobuffermemorydescriptor/1574843-intaskwithphysicalmask.md)
- [initWithPhysicalMask](kernel/iobuffermemorydescriptor/1574833-initwithphysicalmask.md)
- [withOptions](kernel/iobuffermemorydescriptor/1574835-withoptions.md)
- [withCapacity](kernel/iobuffermemorydescriptor/1574841-withcapacity.md)
- [withCopy](kernel/iobuffermemorydescriptor/3074961-withcopy.md)
- [free](driverkit/iobuffermemorydescriptor/free.md)
