[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Defense against a class of programming bugs
>
> >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;
> }
Nah, I'm not kidding...I have to write code that runs on LOTS of platforms
including macs, pcs, and lots of variants of Unix...I assume there's a
lot of others that do as well...you have to make money where you can, and
even with free software given out to the net, you want to make it portable
as a matter of pride.
Patrick
_______________________________________________________________________
/ These opinions are mine, and not Verity's (except by coincidence;). \
| (\ |
| Patrick J. Horgan Verity Inc. \\ Have |
| [email protected] 1550 Plymouth Street \\ _ Sword |
| Phone : (415)960-7600 Mountain View \\/ Will |
| FAX : (415)960-7750 California 94303 _/\\ Travel |
\___________________________________________________________\)__________/