Re: Defense against a class of programming bugs
17 Dec
2003
17 Dec
'03
11:17 p.m.
Unfortunately, strdup is not posix compliant. If you want to use it and maintain portability, you'll have to write your own.
Er, you're kidding, right? drand48 isn't in Posix either, for example. Someone who runs on Motif and Mac has strdup as the least of their worries. But just in case it's stopping anyone: char *strdup(const char *x) { char *p; return (p = malloc(strlen(x) + 1)) ? strcpy(p, x) : 0; } (Deliberately written too-cleverly. Lame compilers will need to cast to 0)
8073
Age (days ago)
8073
Last active (days ago)
0 comments
1 participants
participants (1)
-
Rich Salz