Re: strdup(NULL) supposed to create SIGSEGV?
Hi,
I recently had to tell someone that "strncpy" does not always zero terminate
the destination string. Surprised by what I was telling they immediately
wanted to change the way the function worked. When a function is defined by
an ISO standard you are not supposed to change the definition. Instead I
pointed the person at "strlcpy". Else you will have serious trouble when code
is ported to a new platform.
http://www.gratisoft.us/todd/papers/strlcpy.html
The name "strdup" is very appealing, but it has already been taken and
defined. You have to give your variant a different name and convince everyone
that your function is good and solves a problem so that it deserves to be in
the C-library.
Then you simply run a script on your code:
sed -s "s/ strdup[(]/ strsdup(/g" *.[ch]
--HPS
:-)
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
討論串 (同標題文章)
完整討論串 (本文為第 21 之 25 篇):