G
Geoff
What's "better" depends. I like using this idiom:
if (trim(p) < 0)
printf ("we have a problem\n");
Using my way you can write
if(!trim(&p, &length)
printf("we have a problem")
Are Windows idioms superior to UNIX idioms?
Some are, some aren't. There's always a trade-off.
I'm sure someone will spot it soon enough. It's so basic even K&R
talked about making sure to get it right, and it is a major design
flaw of getchar's interface. Of course, these days of Unicode we don't
have to worry about char anymore.
linux fork() is fast enough that many apps don't need threads. Someone
who needs threads can try writing trim_r().
Why pollute the system with thread safe and non-thread safe functions
that do identical things when you can design one thread-safe,
reentrant function for all environments?
Surely, you don't want to make the same mistake Microsoft did in their
libraries and have to build thread safe libs and non-thread safe libs
and then have to document them and tell programmers when to link them?