News for hackers. Stuff that matters.
Re:C: A Technological Landmine by jrockway on Friday July 31, 2009 @03:54PM (#735222)
Actually, c-strings are a speed-for-memory trade-off. At the expense of saving a few bytes of memory per string, most operations are O(n) time (strlen, for example). If c-strings were in the form of <length><data> instead of <data><\0>, this bug would be avoided.

This is not a performance issue, only bad design and convention. (The other problem was using memcpy and strcmp on the same data. You can't treat blocks of memory as strings; a type system would eliminiate this confusion at no runtime cost.)

There are no comments on this comment yet.