Duplicate a string and return a safe buffer.
Duplicate a string and return a safe buffer. The Linux strndup() function uses a memory allocation function that its own documentation warns against. Win32, and possibly other systems, don't have strndup() at all (and I'm not going to research the names on every platform). This function is a working, hopefully safe, implementation of it.The old strndup() is undefined by Xiqual, and by including xios.h, you'll get strndup defined as xi_strndup. This applies to all platforms. The function itself resides in the core xitools library.
(Linux strndup() uses alloca(), which allocates memory in such a way that the memory is no longer safe to use once the calling function returns. This is clearly not good enough for a library where lots of nodes might be created and passed around like bongs at Woodstock.)