News for hackers. Stuff that matters.
Re:The lost malloc() by teo_zero on Wednesday November 04, 2026 @07:32PM (#50373409)
> I can't think of a single time where you DON'T know what `count` is

A string created by strdup().

Re:The lost malloc() by cowlevel on Wednesday November 04, 2026 @08:42PM (#50373997)
Then you know it's strlen+1
Re:The lost malloc() by teo_zero on Thursday November 05, 2026 @01:02AM (#50375745)
So you don't know it: you must calculate it, via an expensive strlen().
Re:The lost malloc() by NekkoDroid on Thursday November 05, 2026 @03:24AM (#50376600)
To be fair, that is a downstream effect of C's worst mistake (NUL terminated strings). Also, if every allocation you'd get is ptr+size you could just derive it by also copying the size.

Basically, the issue is C having unsized allocations and related not tracking string length.