User: Password:
|
|
Subscribe / Log in / New account

Null-Terminated Strings

Null-Terminated Strings

Posted Nov 18, 2010 18:03 UTC (Thu) by nevyn (guest, #33129)
In reply to: Null-Terminated Strings by pr1268
Parent article: Ghosts of Unix past, part 3: Unfixable designs

I do: http://www.and.org/ustr/

I think it solves almost all the "normal" problems people have with non-nil terminated strings:

1. You can easily allocate them on the stack.

2. You can easily allocate them in constant memory.

3. "" and "x" don't have overhead in the 1,000% range (depending on how you count).

...but still has good solutions to the nil terminated strings problems, in that it allows you to have know the allocated size and length used (and put \0 in your string).

Saying that, the solution was far from obvious ... so while I think it would have been usable in the 1970s, using NIL terminated strings was much more obvious.


(Log in to post comments)


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds