News for hackers. Stuff that matters.
Re:C Strings and my slow descent to madness by attractivechaos on Thursday April 06, 2023 @01:10PM (#35471350)
> especially on the memory management side.

Libc string functions don't manage memory. They can be used no matter where your strings are stored. It is more of a choice between generality vs convenience in common cases.

Re:C Strings and my slow descent to madness by nicoburns on Thursday April 06, 2023 @02:11PM (#35472148)
A lot of them require the string to be null terminated rather than taking a length.
Re:C Strings and my slow descent to madness by stephc_int13 on Thursday April 06, 2023 @02:19PM (#35472273)
I think this is the main culprit of the libc string functions, you have to provide buffers to store results, and the responsibility of managing those individually can be annoying, and bug prone, resulting in vulnerabilities.

Passing an allocator (like Zig) or a container (like in my framework) to anything that needs to allocate some memory to store a result is both explicit, low overhead and quite convenient in practice.

Re:C Strings and my slow descent to madness by bandrami on Friday April 07, 2023 @03:09AM (#35478978)
Note that they're annoying, bug prone, and vulnerable in 3rd-party memory managed libraries, too, but you can just say it's someone else's problem then.
Re:C Strings and my slow descent to madness by skitter on Thursday April 06, 2023 @03:22PM (#35473128)
You cannot e.g. store a string as a slice of another string (unless the slice reaches the end).