>> tam_key = (strchr(string, '=') - string); >> - newopt->key = (char *)malloc(tam_key); >> + newopt->key = (char *)malloc(tam_key + 1); >> strncpy(newopt->key, string, tam_key); >> newopt->key[tam_key] = '\0'; >> newopt->value = strdup(strchr(string, '=') + 1); > > Is strndup() portable enough to be used here? I don't see any other > instances yet in the xserver git master or any of the other X.Org > trees I have checked out. > > It's not in our traditional Unix98 baseline, but > http://pubs.opengroup.org/onlinepubs/9699919799/functions/strdup.html > says it's in the 2008 version of POSIX.
I added strndup to Apple's Libc during Lion development, so it is there for most recent release, but not previous releases. There are a non-trivial number of users who want to build X11 bits on older versions of the OS, and I'd rather not provide an in-project implementation of strndup just for these users of kdrive. That being said, I wouldn't be opposed to bumping our baseline from Unix98 to something more modern, but SUSv4 doesn't even have a test suite yet, so I'd prefer picking SUSv3 as that target. _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel