Re: strdup(NULL) supposed to create SIGSEGV?

看板FB_hackers作者時間17年前 (2008/04/24 02:57), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串20/25 (看更多)
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"
文章代碼(AID): #183uQs00 (FB_hackers)
討論串 (同標題文章)
文章代碼(AID): #183uQs00 (FB_hackers)