strncpy
P E Smee
exspes at gdr.bath.ac.uk
Fri Dec 22 21:20:20 AEST 1989
In article <11510 at csli.Stanford.EDU> poser at csli.stanford.edu (Bill Poser) writes:
>
>I should clarify that: (a) I know perfectly well HOW strncpy works. My
>question concerned the rationale for this design;
I suspect it has to do with the original design of the unix directory
structure. Filenames were limited to 12 (14? been so long since I
used one, I'm not sure of the number) characters, and the directory
structure had a char[exactly-that-size] variable to HOLD the filename.
So, when putting a filename into or out of a directory structure, you
wanted it to be null-terminated if and only if it was shorter than that
variable. A maximum-length filename could NOT be null terminated in
the describing structure.
As to why they decided to do that, sheer byte-saving, I suppose (1 per
file in your directory hierarchy). Maybe it made directory entries fit
more nicely into whatever their disk blocksize was.
--
Paul Smee, Univ of Bristol Comp Centre, Bristol BS8 1TW, Tel +44 272 303132
Smee at bristol.ac.uk :-) (..!uunet!ukc!gdr.bath.ac.uk!exspes if you MUST)
More information about the Comp.lang.c
mailing list