[clug] [OT] Null-terminated strings: expensive mistake or not

Sam Couter sam at couter.id.au
Thu Aug 4 03:48:43 MDT 2011

steve jenkin <sjenkin at canb.auug.org.au> wrote:
> A friend sent me this link making a case that null-terminated strings
> were "The Most Expensive One-byte Mistake".
> I think it was exactly right at the time:
>  - fits the Unix Philosophy: simple and definitive solutions
>  - falls naturally out of C and how it handles pointers

These two criteria are also fulfilled by a length + start tuple,
assuming sizeof(length) is large enough. A slightly different option is
a pair of start + end pointers.

> Which begs the question:

Am I the only pedant who wants to scream "That's not begging the


>   Is it right for now?

Not very often. I think most modern software should be written in
languages other than C, and software that's written in C should strive
to avoid NUL-terminated strings.
Sam Couter         |  mailto:sam at couter.id.au
OpenPGP fingerprint:  A46B 9BB5 3148 7BEA 1F05  5BD5 8530 03AE DE89 C75C
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.samba.org/pipermail/linux/attachments/20110804/5a00e559/attachment-0001.pgp>

More information about the linux mailing list