* fixed memory corruption in trgobj.add_to_movelist on 64 bit platforms

git-svn-id: trunk@9523 -
This commit is contained in:
Jonas Maebe 2007-12-25 23:39:28 +00:00
parent 58600c71b9
commit 8d9bfcaa7d

View File

@ -661,7 +661,8 @@ unit rgobj;
begin
if movelist=nil then
begin
getmem(movelist,sizeof(tmovelistheader)+60*sizeof(pointer));
{ don't use sizeof(tmovelistheader), because that ignores alignment }
getmem(movelist,ptrint(@movelist^.data)-ptrint(movelist)+60*sizeof(pointer));
movelist^.header.maxcount:=60;
movelist^.header.count:=0;
movelist^.header.sorted_until:=0;
@ -671,7 +672,8 @@ unit rgobj;
if movelist^.header.count>=movelist^.header.maxcount then
begin
movelist^.header.maxcount:=movelist^.header.maxcount*2;
reallocmem(movelist,sizeof(tmovelistheader)+movelist^.header.maxcount*sizeof(pointer));
{ don't use sizeof(tmovelistheader), because that ignores alignment }
reallocmem(movelist,ptrint(@movelist^.data)-ptrint(movelist)+movelist^.header.maxcount*sizeof(pointer));
end;
end;
movelist^.data[movelist^.header.count]:=data;