Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: