Re: Storing variable length data in file -- Paging
From: Walter Roberson (roberson_at_ibd.nrc-cnrc.gc.ca)
Date: 02/26/05
- Next message: Jens.Toerring_at_physik.fu-berlin.de: "Re: having trouble with basic multithreading"
- Previous message: Walter Roberson: "Re: where does cc send the output by default"
- In reply to: CBFalconer: "Re: Storing variable length data in file -- Paging"
- Next in thread: Joe Wright: "Re: Storing variable length data in file -- Paging"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Feb 2005 17:13:40 GMT
In article <42208920.E344C9CC@yahoo.com>,
CBFalconer <cbfalconer@worldnet.att.net> wrote:
:A simpler scheme is to assign the high bit of each byte to mean
:'more', and extract 7 bits per byte. This would be something like:
: #define HIBIT 128
Minor phrasing nit. For this scheme, you do not want to assign
the "high" bit of each byte to mean 'more', you want to assign
a -fixed- platform-independant bit for that purpose. Which is
what your code does.
: ch = getc(f); value = 0;
This discussion leads me to ponder platform independance of the
database a bit more.
I do not have my copy of the C89 standard with me and cannot get
it today (building construction work), so perhaps someone could
answer to these points?
a) getc() is defined in terms of 'characters'. For this purpose,
is 'character' equivilent to 'byte' (that is, basic fetchable
units), or is 'character' potentially a multi-byte entity
(e.g., unicode). [I've probably been reading too much about
perl streams...]
b) Are fread() and fwrite() defined in terms of specific numbers
of bits per byte? If not, then if a file is written using
fwrite() on one platform, and is then taken to another platform,
the data that is read in may not have the same byte or character
boundaries. The result would then depend upon the nature of the
process of "taking it to another platform" (e.g., if I recall
correctly, ftp would normally do bytewise renormalization). This,
of course, in addition to the usual problem that
fwrite( (char *)&value, sizeof(value), 1, STREAM) is going to
write in a platform-dependant byte order.
I guess all this was why xdr was invented...
-- Admit it -- you peeked ahead to find out how this message ends!
- Next message: Jens.Toerring_at_physik.fu-berlin.de: "Re: having trouble with basic multithreading"
- Previous message: Walter Roberson: "Re: where does cc send the output by default"
- In reply to: CBFalconer: "Re: Storing variable length data in file -- Paging"
- Next in thread: Joe Wright: "Re: Storing variable length data in file -- Paging"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|