🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.language.objectpascal
1 messages
1 total messages Started by Christopher Tue, 20 Jul 2004 10:50
Dispose Untyped Pointer
#22
Author: Christopher
Date: Tue, 20 Jul 2004 10:50
42 lines
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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads