Subject: semantics of off_t changes
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: Matthieu Herrb <matthieu@laas.fr>
List: current-users
Date: 04/11/1994 19:09:24
While I was browsing through X sources to propagate the off_t change,
the following observation came to my mind:
The fact that off_t is 64 bits while size_t is still 32 bits means
that a file cannot allways be loaded in memory in one read().
This is quite awful ! X sources (and other) are full of code like:
fstat(fd, &st);
buf = malloc(st.st_size);
if (buf == NULL) {
/* error */
...
}
if (read(fd, buf, st.st_size) != st.st_size) {
/* error */
....
}
which obviously can fail if the file is large enough.
In the case of X, I suppose that (st.st_size > 2^31) is an error
condition anyway by in the general case, such code has to be replaced
by an mmap() call (which does take an off_t size).
Comments ?
------------------------------------------------------------------------------