PMEM2_CONFIG_SET_OFFSET(3)

πŸ’– pmem2_config_set_offset() πŸ’–

okay bestie, gather round, because today we're talking about pmem2_config_set_offset() from the PMDK Programmer's Manual β€” yes, the libpmem2 girlies, we love them here. this one sets the offset in the pmem2_config structure. that's it. that's the function. slay. ✨


🌸 SYNOPSIS 🌸

#include <libpmem2.h>

struct pmem2_config;
int pmem2_config_set_offset(struct pmem2_config *config, size_t offset);

like. look at her. two args, one int return, zero drama. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so pmem2_config_set_offset() configures the offset that's gonna be used to map the contents from the specified location of the source. it's giving "start reading from here actually". πŸŽ€

important tho: *config should already be initialized before you call this. please see pmem2_config_new(3) for the details, don't come at her uninitialized, that's not the vibe. πŸ™ˆ

and the value has to be a multiple of the alignment required for the config. yes this is a real requirement, not a suggestion. the alignment requirements are specific to a data source, so like, they change depending on what you're working with. to retrieve the alignment required for a specific instance of pmem2_source, use pmem2_source_alignment(3). go ask her, she'll tell you. 🧚

oh and by default? the offset is 0. classic. main character energy, starts at zero. ⭐


πŸ‘‘ RETURN VALUE πŸ‘‘

pmem2_config_set_offset() returns 0 on success, or a negative error code on failure. that's it, that's the whole story. 0 = we ate. negative = we did not eat. 😭


πŸ”₯ ERRORS πŸ”₯

she can fail, and here's how, bestie:

  • PMEM2_E_OFFSET_OUT_OF_RANGE β€” argument out of range, offset is greater than INT64_MAX
so if your offset is bigger than INT64_MAX, she's gonna say no. and honestly? fair. that's a lot of offset. πŸ’€

🌈 SEE ALSO 🌈

libpmem2(7), pmem2_source_alignment(3), pmem2_config_new(3), pmem2_map_new(3), sysconf(3) and https://pmem.io


and that's the whole page, no notes, no cap. go forth and set your offsets correctly, the alignment is not gonna check itself. 🫢

this has been your girl, signing off on behalf of the PMDK crew β€” dated 2025-07-24, version PMDK. mwah. πŸ’‹πŸ’–

πŸ“¦ where this page comes from