The standard library avoids memory allocation in general. Even strdup is a non-standard extension. It is not safe to assume that the developer is using malloc, or how he is allocating memory. Therefore, any function which needs variable-sized memory is left as an exercise to the reader (which should be trivial and just included in your own general purpose library).
There are a variety of general helper libraries out there. Feel free to use mine:
https://notabug.org/yzziizzy/sti
https://github.com/yzziizzy/sti
