Autor Beitrag
rizor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Mi 20.12.06 17:52 
hallo,

ich habe folgendes Problem.
Ich habe in einer Procedure einen dynamischen array der sich immer erweitert.
Werden die davor beschriebenen array-positionen beibehalten oder werden die gelöscht?


Moderiert von user profile iconChristian S.: Topic aus Sonstiges (Delphi) verschoben am Mi 20.12.2006 um 22:02
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 20.12.06 17:55 
Beibehalten. Probier's doch einfach aus. ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 20.12.06 17:57 
Wenn du per SetLength das Array vergößerst, wird das Array an eine Speicherstelle kopiert, wo genügend Platz ist. Die Antwort auf deine Frage ist also: Nein, die Daten werden nicht gelöscht.

Allerdings solltest du das nicht zu oft machen, da dadurch der Speicherverbrauch deiner Anwendung übermäßig ansteigen kann, und das ganze recht lange dauert. Besser ist es, dass Array einmal auf die richtige Größe zu setzen und dann zu füllen. Oder, bei einem Verlängern des Arrays direkt einen "Puffer" einbauen, damit noch was mehr rein passt.
Konstrukte wie TList, die auf Arrays basieren, vergrößern das Array bei Bedarf immer um 25%.

_________________
We are, we were and will not be.