It was thus said that the Great Coroutines once stated:
I was off-base when I said mmap() -- I haven't used mmap() often and for
some reason I thought I could take a [page-sized] block of memory and get
an fd from it. WRONG. I was really thinking of shm_open().
shm_open() doesn't do what you think it does.
int shm_open(const char *name, int oflag, mode_t mode);
That "name" there is the name of a file; if the name doesn't exist, a file
is created with that name (and I'm checking the man pages of three different
systems here).
No, what you want is open_memstream(). It's a POSIX function, so it'll
exist on Linux and Mac.