You may have misunderstood you, but it seems to me that you are creating memory structures that you hope will be byte-byte, an accurate representation of what you want to read from the hard drive, and then copy all the material to memory and to manipulate from there?
If this is true, you are playing a very dangerous game. At least in C, the standard does not apply such things as filling or aligning structural elements. Not to mention such things as big / small endianness or a parity bit ... So even if your code works very non-portable and risky, you depend on the creator of the compiler without changing it in future versions.
It is better to create an automaton for checking the validity of the read structure (byte per byte) from HD and filling the structure in memory, if it is really OK. You can lose a few milliseconds (not as much as modern OSs seem to do a lot of caching on disk), although you get platform and compiler independence. In addition, your code will be easily ported to another language.
Post Edit: To some extent, I sympathize with you. In the good days of DOS / Win3.11, I once created a C program to read BMP files. And he used the exact same technique. Everything was fine until I tried to compile it for Windows - oops !! Int was now 32 bits long, not 16! When I tried to compile Linux, it was discovered that gcc has very different rules for allocating bit fields than Microsoft C (6.0!). I had to resort to macro tricks to make it portable ...
Joe Pineda Nov 10 '08 at 15:58 2008-11-10 15:58
source share