Vote UpVote

Managed types vs. GetMem

Delphi Haven – I’ve just seen the following question on StackOverflow: I am getting an unexpected AV in the following code: program Project65; {$APPTYPE CONSOLE} {$R *.res} uses SysUtils; type ITest = interface end; TTest = class(TInterfacedObject, ITest) end; var p: ^ITest; begin GetMem(p, SizeOf(ITest)); p^ := TTest.Create; // AV here try finally p^ := nil; FreeMem(p); end; end. Now interestingly if I change the first line to GetMem(p, 21); than the AV is gone. (20 bytes or less fails). What is the explanation to this? Simple: GetMem, as stated by the ...
Favorite? Off-Topic? Chris Rolliston @ 2012-06-12 02:37


Visits: 858
Votes: 1
Favorites: 0
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Yogi Yang
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News


Please login or register to use this functionality.
(click on this box to dismiss)