Live data from Hacker News

Stop using strncpy already (2013)

randomascii.wordpress.com

81–83 of 83 posts

Re: Stop using strncpy already (2013)

#81
post #74

Earlier quoted context omitted.

Sure you can, that is what Abstract Data Types architecture design is all about. Naturally, when one creates struts and accesses the fields directly there is no way out of a bad design.

That's a pipe dream. There are a handful of successful abstractions, like streams or associative containers, or strings for that matter. Even those quickly get too abstract for serious use, and you need to actually expose what's really happening to make sensible choices, because there are vastly different kinds of streams or containers (or even strings), because, well, those are abstractions. Other more far reaching…

A pipe dream delivered into production around 2000, for a distributed CRM platform running across Aix, Solaris, HP-UX, Red-Hat Linux, Windows NT/2000.

Re: Stop using strncpy already (2013)

#82
post #41

Earlier quoted context omitted.

Of course, but everyone wants to overdo the complexity of the time worn solution. OMG you need to null terminate the string after all the _other_ gymnastics..gee C sure does suck! Why don't we use rust|go|c++ ad-nauseam. bzero(buf,sz); / memset nazis here / strncpy(buf,src,sz - 1);

It doesn't make sense to have to null-terminate the string by hand (maybe) after doing a "safe" STRING copy. Which means it's easy to forget to do and that's a dangerous wart in the design. Really, stop using C. To quote Hayao Miyazaki, C was a mistake.

Teach your grandmother to suck eggs and resign the thought police please.

Re: Stop using strncpy already (2013)

#83
post #41

Earlier quoted context omitted.

It doesn't make sense to have to null-terminate the string by hand (maybe) after doing a "safe" STRING copy. Which means it's easy to forget to do and that's a dangerous wart in the design. Really, stop using C. To quote Hayao Miyazaki, C was a mistake.

Teach your grandmother to suck eggs and resign the thought police please.

Posting like this will get you banned here. Please review and follow the rules: https://news.ycombinator.com/newsguidelines.html.
Post reply on HN