Registriert seit: 2. Nov 2003
Ort: Schweiz
407 Beiträge
Turbo Delphi für Win32
|
Re: Insert/Delete mit PChar
1. Aug 2004, 22:13
Ich habs schliesslich selbst rausgefunden . So gehts ein bisschen schneller:
Delphi-Quellcode:
procedure InsertBuffer(var Dest: PChar; const DestSize: Integer;
const Buffer: PChar; const BufferSize: Integer; const Index: Integer);
var
Dest2: PChar;
begin
GetMem(Dest2, BufferSize + DestSize);
Move(Dest^, Dest2^, Index);
Move(Buffer^, (Dest2 + Index)^, BufferSize);
Move((Dest + Index)^, (Dest2 + Index + BufferSize)^, DestSize - Index);
FreeMem(Dest, DestSize);
Dest:= Dest2;
end;
function DeleteBuffer(var Dest: PChar; const DestSize: Integer; const Index, Count: Integer): Integer;
var
Dest2: PChar;
begin
GetMem(Dest2, DestSize - Count);
Move(Dest^, Dest2^, Index);
Move((Dest + Index + Count)^, (Dest2 + Index)^, DestSize - Index - Count);
FreeMem(Dest, DestSize);
Dest:= Dest2;
end;
Gruss
Shaman
Daniel Pauli Looking for answers from the great beyond
|
|
Zitat
|