Defense against a class of programming bugs

Rich Salz rsalz at osf.org
Sun Sep 24 20:50:11 PDT 1995


>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)






More information about the cypherpunks-legacy mailing list