PMEM2_CONFIG_SET_LENGTH(3)

πŸ’– PMEM2_CONFIG_SET_LENGTH(3) πŸ’–

okay bestie, welcome to the PMDK Programmer's Manual, page PMEM2_CONFIG_SET_LENGTH(3) β€” yes the title is a whole mouthful, iykyk, but we're gonna make it make sense 🫢


✨ NAME ✨

pmem2_config_set_length() β€” set length in the pmem2_config structure 🌸


✨ SYNOPSIS ✨

#include <libpmem2.h>

struct pmem2_config;
int pmem2_config_set_length(struct pmem2_config *config, size_t length);

✨ DESCRIPTION ✨

so like, pmem2_config_set_length() sets up the length that's gonna be used for mapping. that's literally its whole job πŸ’…

quick vibe check though: *config needs to already be initialized before you call this, no exceptions. if you're like "girl, how do i even do that", go read pmem2_config_new(3), it's all there πŸŽ€

also β€” and this part is important, don't skip it β€” the length must be a multiple of the alignment required for the data source that's gonna be used for mapping alongside the config. like, the alignment and the length have to be in a committed relationship, fr fr.

need to know what alignment your specific pmem2_source wants? that's pmem2_source_alignment(3), she'll tell you πŸ¦‹

and by default, if you don't set anything, the length is equal to the size of the file that is being mapped. cute, right? it just figures it out for you ✨


✨ RETURN VALUE ✨

pmem2_config_set_length() always returns 0. always. no drama, no error codes, no surprises. she is unbothered, moisturized, in her lane πŸ‘‘


✨ SEE ALSO ✨


reminder bestie: init the config first, keep that length alignment-friendly, and you're golden πŸ’œ

that's the whole page!! mwah πŸ’‹ this was PMDK's manual, dated 2025-07-24, brought to you by the PMDK Programmer's Manual herself β€” go slay some mappings, you've got this 🌈⭐

πŸ“¦ where this page comes from