Comment

Comment by matheusmoreira

So why insist on this NUL termination business? I expected this to be necessary in C libraries due to legacy code but the kernel can always do whatever it wants internally.

  struct bytes { size_t size; unsigned char *pointer; };
Seems simple enough... A little structure like that has always been useful in my projects.

I find myself agreeing with the glibc maintainer in the extended discussion linked from the article:

https://lwn.net/Articles/612244/

> Correct string handling means that you always know how long your strings are and therefore you can you memcpy (instead of strcpy).

I think he's absolutely right. The str* functions are just worse versions of the mem* functions.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton