PMEM2_SOURCE_FROM_ANON(3)

πŸ’– NAME πŸ’–

okay so pmem2_source_from_anon() β€” it literally creates a data source backed by anonymous memory pages. that's the whole vibe. it's part of the PMDK Programmer's Manual bestie, and yes we're about to get into it 🫢


✨ SYNOPSIS ✨

#include <libpmem2.h>

int pmem2_source_from_anon(struct pmem2_source **src, size_t size);

πŸ¦‹ DESCRIPTION πŸ¦‹

so pmem2_source_from_anon() instantiates a brand new struct pmem2_source object that describes an anonymous data source. main character energy fr πŸ’…

here's the tea: mappings created using this function are not backed by any file β€” and they're zero-initialized. no file, all vibes, everything starts at zero 🌸

the size argument defines the length in bytes of the anonymous source, exactly as returned by pmem2_source_size(3). and bestie, you should set this value so that it's greater than or equal to the size of any mapping you create with the anonymous source. size it up properly, no cap πŸ‘‘

also β€” the offset value for mapping is ignored. just straight up not invited to the party πŸ™ˆ


🌈 RETURN VALUE 🌈

  • pmem2_source_from_anon() returns 0 on success β€” slay ✨
  • or a negative error code on failure β€” not slay 😭

πŸ’€ ERRORS πŸ’€

okay so pmem2_source_form_anon() can fail with the following errors:

  • -ENOMEM β€” in case of insufficient memory to allocate an instance of struct pmem2_source. it's giving "your RAM said no" πŸ’€

πŸŽ€ SEE ALSO πŸŽ€

errno(3), pmem2_config_set_length(3), pmem2_map_new(3), pmem2_source_size(3), pmem2_config_set_length(3), libpmem2(7) and https://pmem.io

(and yes bestie, pmem2_config_set_length(3) really is listed twice β€” iconic of it honestly πŸ‘‘)


that's the whole page!! this was PMDK, dated 2025-07-24. go forth and map your anonymous memory, bestie πŸ’œπŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from