You need to make it a "packed" record (TSample = packed record etc).
16 is the "real size" of what you declared, due to alignment, and the
Size allocated will be "correct".
Make it packed and it changes to 15.

Regards,
Ken

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of CubicDesign
Sent: 16 May 2007 16:20
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


-- 
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.467 / Virus Database: 269.7.1/807 - Release Date: 16/05/2007
18:05


_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to