---
name: "pmem2_map_delete"
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_map_delete"
---

# pmem2\_map\_delete(3)

deletes a mapping

## NAME

**pmem2\_map\_delete**() - deletes a mapping

## SYNOPSIS

-

  ```
  #include <libpmem2.h>
  int pmem2_map_delete(struct pmem2_map **map_ptr);
  ```

## DESCRIPTION

The **pmem2\_map\_delete**() function deletes the mapping described by the *struct pmem2\_map* object.

If **pmem2\_map\_delete**() succeeds in deleting the mapping, it releases the *struct pmem2\_map* object describing it and writes a NULL value to *map\_ptr*. If the function fails, the *map\_ptr* variable and the map object itself are left unmodified and appropriate error value is returned. For a list of possible return values please see RETURN VALUE.

The **pmem2\_map\_delete**() function will not unmap mapping provided by the user by **pmem2\_map\_from\_existing**() function. In such case it will only free *struct pmem2\_map* object.

## RETURN VALUE

The **pmem2\_map\_delete**() function returns 0 on success or a negative error code on failure.

## ERRORS

The **pmem2\_map\_delete**() can fail with the following errors:

- •

  **PMEM2\_E\_MAPPING\_NOT\_FOUND** - mapping was not found (it was already unmapped or pmem2\_map state was corrupted)

On systems other than Windows it can also return **-EINVAL** from the underlying [**munmap**(2)](/munmap/2.md) function.

## SEE ALSO

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