PMEM2_CONFIG_NEW(3)

πŸ’– PMEM2_CONFIG_NEW, PMEM2_CONFIG_DELETE πŸ’–

okay bestie so this is from the PMDK Programmer's Manual and it's literally the glow-up your libpmem2 mapping config deserves ✨ two little functions that make and unmake a configuration struct, no cap.


🌸 NAME 🌸

pmem2_config_new(), pmem2_config_delete() β€” allocate and free a configuration structure for a libpmem2 mapping 🫢


✨ SYNOPSIS ✨

#include <libpmem2.h>

struct pmem2_config;
int pmem2_config_new(struct pmem2_config **cfg);
int pmem2_config_delete(struct pmem2_config **cfg);

πŸ’… DESCRIPTION πŸ’…

so pmem2_config_new() instantiates a brand-new (opaque) configuration structure, pmem2_config, and hands it back to you through the pointer in *cfg β€” it's giving main character energy tbh. this struct is the whole vibe-setter: it's what you use to define mapping parameters for a pmem2_map_new() function. πŸ‘‘

New configuration is always initialized with default values for most parameters, and those defaults are specified alongside the corresponding setter function (iykyk, go read the setter docs). but heads up: the application must explicitly set the granularity value for the mapping. no skipping that step fr fr.

Then pmem2_config_delete() frees *cfg (the one that pmem2_config_new() gave you) and sets *cfg to NULL. 🧹 and if *cfg is already NULL? no operation is performed. it just minds its business. iconic behavior honestly. πŸ’…


πŸ”₯ RETURN VALUE πŸ”₯

pmem2_config_new() returns 0 on success or a negative error code on failure. and yes, pmem2_config_new() does set *cfg to NULL on failure β€” clean, no dangling weirdness. 🧚

pmem2_config_delete() always returns 0. every single time. zero drama. πŸŽ€


😭 ERRORS 😭

pmem2_config_new() can fail with the following error:

  • -ENOMEM β€” out of memory πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

errno(3), pmem2_map_new(3), pmem2_config_get_file_size(3), libpmem2(7) and https://pmem.io 🌈


and that's the whole page, bestie!! πŸ¦‹ this one came from the PMDK crew, dated 2025-07-24 β€” go forth and configure your mappings, you absolute legend. πŸ’–βœ¨πŸŽ€πŸŒΈπŸ’œ

πŸ“¦ where this page comes from