[TUHS] Terms for string, and similar character constructs (was: origin of null-terminated strings)

Alejandro Colomar alx.manpages at gmail.com
Sat Dec 17 08:30:34 AEST 2022


[Resend from my subscribed address, as the list is subscribers-only, it seems]

In C, most syscalls and libc functions use strings, that is, zero or more 
non-NUL characters followed by a NUL.

However, there are a few cases where other incompatible character constructs are 
used.  A few examples:

-  utmpx(5): Some of its fields use fixed-width char arrays which contain a 
sequence of non-NUL characters, and padding of NULs to fill the rest (although 
some systems only require a NUL to delimit the padding, which can then contain 
garbage).

-  Some programs use just a pointer and a length to determine sequences of 
characters.  No NULs involved.

-  abstract sockets:  On Linux, abstract Unix socket names are stored in a 
fixed-width array, and all bytes are meaningful (up to the specified size), even 
if they are NULs.  Only special that that the first byte is NUL.

Since those are only rare cases, those constructs don't seem to have a name; 
some programmers call them strings (quite confusingly).

Has there been any de-facto standard (or informal naming) to call those things, 
and differentiate them?


Thanks,

Alex

-- 
<http://www.alejandro-colomar.es/>


More information about the TUHS mailing list