---
name: "sam_data_restore"
section: "3"
platform: "linux"
package: "libsam-dev"
version: "3.1.9-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/sam_data_restore"
---

# sam\_data\_restore(3)

Restore previously saved user data

## NAME

sam\_data\_restore - Restore previously saved user data

## SYNOPSIS

**#include \<corosync/sam.h\>**

**cs\_error\_t sam\_data\_restore (void \****data***, size\_t** *size***);**

## DESCRIPTION

The **sam\_data\_restore** function is used to restore data, previously saved by calling **[sam\_data\_store(3)](/sam_data_store/3.md)**. Such data survives between instances.

The *data* parameter is pointer to memory initialized by caller. Stored data are copied there. This also means, that caller is responsible for freeing memory.

The *size* parameter is length of *data*. This one must be at least same length as previously stored data otherwise error is returned. Parameter can be larger but only stored data size bytes are changed.

Use **[sam\_data\_getsize(3)](/sam_data_getsize/3.md)** to find out length of stored data.

## RETURN VALUE

This call return CS\_OK value if successful, otherwise and error is returned.

## ERRORS

- CS\_ERR\_BAD\_HANDLE

  component was not initialized by calling **[sam\_initialize(3)](/sam_initialize/3.md)** or it was finalized.

- CS\_ERR\_INVALID\_PARAM

  data parameter is NULL or size is less then currently stored data length

## SEE ALSO

[**sam\_data\_getsize**(3)](/sam_data_getsize/3.md), [**sam\_data\_store**(3)](/sam_data_store/3.md)

**CS\_ERR\_TRY\_AGAIN** Resource temporarily unavailable

**CS\_ERR\_INVALID\_PARAM** Invalid argument

**CS\_ERR\_ACCESS** Permission denied

**CS\_ERR\_LIBRARY** The connection failed

**CS\_ERR\_INTERRUPT** System call interrupted by a signal

**CS\_ERR\_NOT\_SUPPORTED** The requested protocol/functionality not supported

**CS\_ERR\_MESSAGE\_ERROR** Incorrect auth message received

**CS\_ERR\_NO\_MEMORY** Not enough memory to complete the requested task
