---
name: "pmem2_source_from_anon"
section: "3"
platform: "linux"
package: "libpmem2-dev"
version: "1.13.1-1.1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/pmem2_source_from_anon"
---

# pmem2\_source\_from\_anon(3)

creates data source backed by anonymous memory pages

## NAME

**pmem2\_source\_from\_anon**() - creates data source backed by anonymous memory pages

## SYNOPSIS

-

  ```
  #include <libpmem2.h>
  int pmem2_source_from_anon(struct pmem2_source **src, size_t size);
  ```

## DESCRIPTION

The **pmem2\_source\_from\_anon**() function instantiates a new *struct pmem2\_source* object describing an anonymous data source. Mappings created using this function are not backed by any file and are zero-initialized.

The *size* argument for the function defines the length in bytes of the anonymous source, as returned by [**pmem2\_source\_size**(3)](/pmem2_source_size/3.md). The application should set this value so that it’s greater than or equal to the size of any mapping created with the anonymous source.

The offset value for mapping is ignored.

## RETURN VALUE

The **pmem2\_source\_from\_anon**() function returns 0 on success or a negative error code on failure.

## ERRORS

The **pmem2\_source\_form\_anon**() can fail with the following errors:

- •

  **-ENOMEM** - in case of insufficient memory to allocate an instance of *struct pmem2\_source*.

## SEE ALSO

[**errno**(3)](/errno/3.md), [**pmem2\_config\_set\_length**(3)](/pmem2_config_set_length/3.md), [**pmem2\_map\_new**(3)](/pmem2_map_new/3.md), [**pmem2\_source\_size**(3)](/pmem2_source_size/3.md), [**pmem2\_config\_set\_length**(3)](/pmem2_config_set_length/3.md), [**libpmem2**(7)](/libpmem2/7.md) and **\<https://pmem.io\>**
