On Thu, Dec 3, 2009 at 10:56 PM, Paul Gilmartin <[email protected]>wrote:
> On Thu, 3 Dec 2009 11:07:38 -0600, McKown, John wrote: > > >OPINION TIME! > > > >The "safe" versions are not safer than using some of the others which > include the length of the destination buffer. Such as strncpy, strncmp, and > so on. The strn... functions are multiplatform and standard. The str..._s > functions, from what I have read on the Web, are a Microsoft invention. They > are not ISO or ANSI standard functions, but are being considered. And, > according to one person, were invented by MS strictly as a way to make it > more difficult to port code using them to other systems. > > > I suppose M$ could argue that there's some advantage (but what?) > in leaving the target buffer unmodified in the failure case. > > -- gil > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to [email protected] with the message: GET IBM-MAIN INFO > Search the archives at http://bama.ua.edu/archives/ibm-main.html > The _s versions of strcpy, etc. provide additional functionality not found in the strn* functions. There are return codes which indicate runtime error conditions which allow the program to take corrective action on the fly. They also guarantee that the receiving buffer is always null terminated, eliminated potential 0c4 abends and other unexpected results. These actions/functionality do require additional design and coding effort to ensure that the desired and actual results are what the program wants/expects. Yes these functions were initiated by MS. But take a close look at what they provide before they are discounted. Sam ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html

