Article View: borland.public.delphi.language.objectpascal
Article #22Dispose Untyped Pointer
From: Christopher
Date: Tue, 20 Jul 2004 10:50
Date: Tue, 20 Jul 2004 10:50
42 lines
1558 bytes
1558 bytes
Is it possible to dispose of an untyped pointer?
I ask because I use TLists of pointers to records a lot and would very
much like to not have to write a TList freeing block of code per
TList.
I'd rather write one function like this
procedure ClearTList(var List: TList);
var
I: Integer;
P: Pointer;
begin
if List.Count > 0 then
begin
for I := 0 to List.Count -1 do
begin
P := List.Items[I];
Dispose(P);
end;
List.Clear;
end;
end;
than lots like this
procedure ClearTimetables;
var
P: PTimetable;
begin
if Timetables.Count > 0 then
begin
for I := 0 to Timetables.Count -1 do
begin
P := Timetables.Items[I];
Dispose(P);
end;
Timetables.Clear;
end;
end;
Thank you very much.
Technical Details
Message-ID:
<78cdb1db.0407200250.62eac2d8@posting.google.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews2.google.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 109d30,468c9cb4c1f70765,start X-Google-Attributes: gid109d30,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews2.google.com!not-for-mail From: google@cja.org.uk (Christopher) Newsgroups: borland.public.delphi.language.objectpascal Subject: Dispose Untyped Pointer Date: 20 Jul 2004 03:50:01 -0700 Organization: http://groups.google.com Lines: 42 Message-ID: <78cdb1db.0407200250.62eac2d8@posting.google.com> NNTP-Posting-Host: 212.159.88.161 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1090320602 22548 127.0.0.1 (20 Jul 2004 10:50:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 20 Jul 2004 10:50:02 +0000 (UTC)