---
name: "pmem2_get_flush_fn"
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_get_flush_fn"
---

# pmem2\_get\_flush\_fn(3)

get a flush function

## NAME

**pmem2\_get\_flush\_fn**() - get a flush function

## SYNOPSIS

-

  ```
  #include <libpmem2.h>
  typedef void (*pmem2_flush_fn)(const void *ptr, size_t size);
  struct pmem2_map;
  pmem2_flush_fn pmem2_get_flush_fn(struct pmem2_map *map);
  ```

## DESCRIPTION

The **pmem2\_get\_flush\_fn**() function returns a pointer to a function responsible for efficiently flushing data in the range owned by the *map*.

Flushing data using *pmem2\_flush\_fn* **does not** guarantee that the data is stored durably by the time it returns. To get this guarantee, application should either use the persist operation (see [**pmem2\_get\_persist\_fn**(3)](/pmem2_get_persist_fn/3.md)) or follow *pmem2\_flush\_fn* by a drain operation (see [**pmem2\_get\_drain\_fn**(3)](/pmem2_get_drain_fn/3.md)).

There are no alignment restrictions on the range described by *ptr* and *size*, but *pmem2\_flush\_fn* may expand the range as necessary to meet platform alignment requirements.

There is nothing atomic or transactional about *pmem2\_flush\_fn*. Any unwritten stores in the given range will be written, but some stores may have already been written by virtue of normal cache eviction/replacement policies. Correctly written code must not depend on stores waiting until *pmem2\_flush\_fn* is called to be flushed – they can be flushed at any time before *pmem2\_flush\_fn* is called.

If two (or more) mappings share the same *pmem2\_flush\_fn* and they are adjacent to each other, it is safe to call this function for a range spanning those mappings.

## RETURN VALUE

The **pmem2\_get\_flush\_fn**() function never returns NULL.

The **pmem2\_get\_flush\_fn**() for the same *map* always returns the same function. This means that it’s safe to cache its return value. However, this function is very cheap (because it returns a precomputed value), so caching may not be necessary.

## SEE ALSO

[**pmem2\_get\_drain\_fn**(3)](/pmem2_get_drain_fn/3.md), [**pmem2\_get\_persist\_fn**(3)](/pmem2_get_persist_fn/3.md), [**pmem2\_map\_new**(3)](/pmem2_map_new/3.md), [**libpmem2**(7)](/libpmem2/7.md) and **\<https://pmem.io\>**
