this:
char *buf = NULL;
scanf("%ms", &buf);
will get a dynamically allocated char buffer. I know this is limited to code compiled with Gcc (and specifically version 2.7 of glibc).
I am also aware that the “correct” and portable way is to just use malloc() (and friends) to get the memory.
I’m curious however, are there any other portable or semi-portable* implementations out there for getting dynamically allocated memory? I find tricks and tips of memory allocation in C a hard topic to “Google”.
Note: This is not “required” for anything, so there are no limitations on answers.
* semi-portable meaning “if you compile the same way I do, this will work”
POSIX has
and
which should qualify as semi-portable.