OK. Well a couple of byte is not a big deal IF the files are small. The
smallest allocation on most large drives is 4K.
If speed is not the issue try a packed record.
"When a record type is declared in the {$A+} state (the default), and when
the declaration does not include a packed modifier, the type is an unpacked
record type, and the fields of the record are aligned for efficient access
by the CPU. The alignment is controlled by the type of each field and by
whether fields are declared together. Every data type has an inherent
alignment, which is automatically computed by the compiler. The alignment
can be 1, 2, 4, or 8, and represents the byte boundary that a value of the
type must be stored on to provide the most efficient access. The table below
lists the alignments for all data types."
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of CubicDesign
Sent: Wednesday, May 16, 2007 10:20 AM
To: [email protected]
Subject: problems with SizeOf
Hi.
Can anybody tell me what should return this function Sizeof(TSample)?
TSample = record
SampleA:
Smallint;
SampleB:
Smallint;
SampleC: Smallint;
SampleD: Smallint;
BasePos: Integer;
Base :
char;
QV : BYTE;
Gray : Boolean;
end; {Size= 2+2+2+2+ 4+ 1+ 1+ 1}
Why it returns 16 instead of 15?
It is because the data is aligned to word or double-word boundaries for
faster access?
How do I get the real size then?
I want to save a matrix called CromaMX (CromaMX = array of TSample ) to
disk using BlockWrite. How do I save it, without wasting disk space,
because it looks that if I use:
SizeChroma= Length(CromaMX)* sizeof(TSample);
BlockWrite(F, CromaMX[0], SizeChroma);
I will allocate too much space.
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi