PMEM2_MAP_DELETE(3)

πŸ’– PMEM2_MAP_DELETE πŸ’–

okay bestie, welcome to the PMDK Programmer's Manual ✨ this one's short, sweet, and honestly kinda iconic β€” it's all about saying bye-bye to a mapping 🫢


🌸 NAME 🌸

pmem2_map_delete() β€” deletes a mapping πŸ’…


✨ SYNOPSIS ✨

#include <libpmem2.h>

int pmem2_map_delete(struct pmem2_map **map_ptr);

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, pmem2_map_delete() deletes the mapping that the struct pmem2_map object is describing. like, it's the breakup function. the mapping is gone, we said what we said πŸ’€

if pmem2_map_delete() succeeds in deleting the mapping, it releases the struct pmem2_map object that was describing it, and it writes a NULL value into map_ptr. clean. tidy. slay ✨

if the function fails tho, then map_ptr variable and the map object itself are both left unmodified, and an appropriate error value is returned. for the full list of possible return values, please see RETURN VALUE below, bestie, I got you 🫢

⚠️ okay important lore: pmem2_map_delete() will not unmap a mapping that the user provided via the pmem2_map_from_existing() function. in that case it will only free the struct pmem2_map object. so don't be out here expecting a full unmapping when it's not that kind of party πŸ™ˆ

πŸ’œ RETURN VALUE πŸ’œ

pmem2_map_delete() returns 0 on success, or a negative error code on failure. that's it, that's the tea πŸ“


πŸ”₯ ERRORS πŸ”₯

pmem2_map_delete() can fail with the following errors:

  • PMEM2_E_MAPPING_NOT_FOUND β€” the mapping was not found (either it was already unmapped, or the pmem2_map state was corrupted) 😭 like where did it go
  • -EINVAL β€” this one comes from the underlying munmap(2) function.

🌈 SEE ALSO 🌈

pmem2_map_new(3), libpmem2(7) and https://pmem.io β€” go read those, iykyk πŸ‘‘


and that's the whole page, you ate that fr fr πŸ’–

signing off from the PMDK corner of the group chat β€” this one's from PMDK, dated 2025-07-24, and no cap, you're gonna remember this one forever πŸŒŸπŸŽ€πŸ¦‹

πŸ“¦ where this page comes from