---
name: "sam_data_store"
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_store"
---

# sam\_data\_store(3)

Store user data

## NAME

sam\_data\_store - Store user data

## SYNOPSIS

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

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

## DESCRIPTION

The **sam\_data\_store** function is used to store data, which survives between instances.

The *data* parameter is pointer to memory with data to store. Data are stored in newly allocated memory inside library, so caller can safely remove them after call of function.

You can use NULL as parameter to remove and free previously saved data. In this case *size* argument is ignored.

The *size* parameter is length of *data*.

Use **[sam\_data\_getsize(3)](/sam_data_getsize/3.md)** to find out length of stored data and **[sam\_data\_restore(3)](/sam_data_restore/3.md)** to restore 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\_NO\_MEMORY

  internal malloc/realloc failed because data are too large

- CS\_ERR\_LIBRARY

  some internal error appeared (mostly because communication with parent process failed)

## SEE ALSO

[**sam\_data\_getsize**(3)](/sam_data_getsize/3.md), [**sam\_data\_restore**(3)](/sam_data_restore/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
