---
title: createFromBytes
framework: driverkit
role: symbol
role_heading: Static Method
path: driverkit/osserialization/createfrombytes-8jjh8
---

# createFromBytes

## Declaration

```occ
static OSSerializationPtr createFromBytes(const void *bytes, size_t length, OSSerializationFreeBufferHandler freeBuffer, OSSerializationPortCopyInHandler copyInHandler);
```

## Parameters

- `bytes`: The serialized data from a previous call to OSSerialization::finalizeBuffer().
- `length`: The length of the serialized data from a previous call to OSSerialization::finalizeBuffer().
- `freeBuffer`: A required block to be called when the OSSerialization is freed and the serialized data will no longer be accessed. Note that unserialized objects may retain the OSSerialization they were created from, so the OSSerialization will retain the data until they have been freed.
- `copyInHandler`: An optional handler that allows a port number to be replaced with an OSObject instance during unserialization

## Return Value

Return Value NULL on failure, otherwise the allocated OSSerialization with reference count 1 to be released by the caller.

## Discussion

Discussion Allocates an OSSerialization object from the serialized data of a previous serialization. Allocates an OSSerialization object from the serialized data of a previous serialization.
