Linux eliminates the strncpy API after six years of work, 360 patches
1–10 of 340 posts
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#2Re: Linux eliminates the strncpy API after six years of work, 360 patches
#3Re: Linux eliminates the strncpy API after six years of work, 360 patches
#4the zero terminated string is I think is computing's biggest mistake. Pascal style strings were much safer.
But at the same time, I think blaming the software was kind of a cop out. Devs were in a hurry and simply didnt respect the rules. Given todays software engineer at large. Nerfing programming languages so they cant destroy things might not be a bad idea. But AI will nerf everything.
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#5I’m not sure why this was - the source base was so old it might have had its origins in Pascal struct behaviour.
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#6I worked on a Win32 app that used space-padded strings, i.e. the destination string was padded with spaces, but there was still a null on the last byte. You had to use special versions of the string functions for length, copy etc. I’m not sure why this was - the source base was so old it might have had its origins in Pascal struct behaviour.
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#7Wonder when is someone going to brave and fork the linux kernel and try to ffwd it with automatic programming.
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#8the zero terminated string is I think is computing's biggest mistake. Pascal style strings were much safer.
It was definitely an interesting way to allocate pointers. I did once have a very large project where devs didnt understand this and resolved hundreds or more off by one and memory overwrites in C due to this feature. But at the same time, I think blaming the software was kind of a cop out. Devs were in a hurry and simply didnt respect the rules. Given todays software engineer at large. Nerfing programming languages…
Why do you assume that AI is gonna nerf everything?
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#9the zero terminated string is I think is computing's biggest mistake. Pascal style strings were much safer.
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#10the zero terminated string is I think is computing's biggest mistake. Pascal style strings were much safer.
The limitations were brutal. Initially you could only have 255 bytes in a string. The length of a string and the size of the allocation are now separate and you may need to think about that unused memory in your design. The problem now doubles with the introduction of UTF-8. Your string size is in bytes and you need to track characters separately.
If you want to create an array of strings you either need to specify the length of all strings and accept the memory overhead or have an array of pointers to strings. If you use an array of pointers you may end up choosing to use the 'nil' value as a sentinel that means "end of list." So we're right back where we started.
--
Because someone decided to downvote this HN has limited the speed at which I can reply. This site is tragic and I'm fully done with it now. You can spread propaganda and poorly sourced zeitgeist and be among friends but if you try to have a genuine conversation about programming languages you are made to be unwelcome immediately. Screw this.
--
> No other data structure works like this.
The linked list.
> You can't mess this up in an array
C happily decomposes arrays into pointers. You can erase your length information from the type. This was an intentional decision.
> Strings are the only data structure that assume there will be a NULL at end.
Which is why almost every string API has a version that allows you to specify the maximum length. The fact that you can use a NUL doesn't mean you have to. Which is why the concept of "sentinel values" is broadly used in many types of applications you haven't considered here.