* Dyn array for ReadArchive variables

This commit is contained in:
Michaël Van Canneyt 2025-03-18 15:41:20 +01:00
parent 4652593a8c
commit 2cd92ee792

View File

@ -26,6 +26,7 @@ unit owar;
interface interface
uses uses
globtype,
cclasses, cclasses,
owbase; owbase;
@ -461,11 +462,11 @@ implementation
symsize : longint; symsize : longint;
arsym : TArSymbol; arsym : TArSymbol;
s : string; s : string;
syms,
currp, currp,
endp, endp,
startp : pchar; startp : integer;
relocs : plongint; syms : TAnsiCharDynArray;
relocs : Array of longint;
begin begin
Read(currarhdr,sizeof(currarhdr)); Read(currarhdr,sizeof(currarhdr));
{ Read number of relocs } { Read number of relocs }
@ -481,23 +482,23 @@ implementation
exit; exit;
end; end;
{ Read relocs } { Read relocs }
getmem(Relocs,relocsize); setlength(Relocs,relocsize);
Read(relocs^,relocsize); Read(relocs[0],relocsize);
{ Read symbols, force terminating #0 to prevent overflow } { Read symbols, force terminating #0 to prevent overflow }
getmem(syms,symsize+1); setlength(syms,symsize+1);
syms[symsize]:=#0; syms[symsize]:=#0;
Read(syms^,symsize); Read(syms[0],symsize);
{ Parse symbols } { Parse symbols }
relocidx:=0; relocidx:=0;
currp:=syms; currp:=0;
endp:=syms+symsize; endp:=symsize;
for relocidx:=0 to nrelocs-1 do for relocidx:=0 to nrelocs-1 do
begin begin
startp:=currp; startp:=currp;
while (currp^<>#0) do while (syms[currp]<>#0) do
inc(currp); inc(currp);
s[0]:=chr(currp-startp); SetLength(s,currp-startp);
move(startp^,s[1],byte(s[0])); move(syms[startp],s[1],currp-startp);
arsym:=TArSymbol.create(ArSymbols,s); arsym:=TArSymbol.create(ArSymbols,s);
arsym.MemberPos:=lsb2msb(relocs[relocidx]); arsym.MemberPos:=lsb2msb(relocs[relocidx]);
inc(currp); inc(currp);
@ -507,8 +508,8 @@ implementation
break; break;
end; end;
end; end;
freemem(relocs); relocs:=nil;
freemem(syms); syms:=nil;
{ LFN names } { LFN names }
Read(currarhdr,sizeof(currarhdr)); Read(currarhdr,sizeof(currarhdr));
if DecodeMemberName(currarhdr)='/' then if DecodeMemberName(currarhdr)='/' then