Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 750127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:30:56+00:00 2026-05-14T14:30:56+00:00

The question more or less says it all. Given the following record structure: type

  • 0

The question more or less says it all. Given the following record structure:

type
    TPerson = record
        Name: string;
        Age: Integer;
    end;
    PPerson = ^TPerson;
    TPersonList = TList<TPerson>;

Is the following code valid?

procedure ReadPeople(DataSet: TDataSet; PersonList: TPersonList);
begin
    PersonList.Count := DataSet.RecordCount;
    if DataSet.RecordCount = 0 then
        Exit;

    DataSet.First;
    while not DataSet.Eof do begin
        PersonList[DataSet.RecNo].Name := DataSet.FieldByName('Name').AsString;
        PersonList[DataSet.RecNo].Age := DataSet.FieldByName('Age').AsInteger;
        DataSet.Next;
    end;
end;

Do I have to use GetMem/FreeMem to allocate and free records an instance of TPersonList, or am I free to directly access the TPersonList entries directly? My gut says that the code should be valid, though I’m not sure if there’s any wrinkles related to record initialization or finalization.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:30:56+00:00Added an answer on May 14, 2026 at 2:30 pm

    Your code’s fine. When you use Tlist<T> with records, it treats them as value types, to be copied around. There’s no need to allocate pointers for them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: This question is more about language engineering than C++ itself. I used C++
Really my question has more to do with the server-side scrubbing of html that's
This is kind of a weird question and more of an annoyance than technical
I'm iterating through a HashMap (see my earlier question for more detail) and building
Here is one more newbie question: require 'tasks/rails' I saw this line in Rakefile
I asked a related question about findbugs, but let's ask a more general question.
More detail to my question: HTML and JavaScript are called client-side code. C# and
This is more of a syntax question I'm trying to write a store procedure
My question seems easy but is little more theoretical than it looks. There are
On a more abstract level then a previous question , in my experience there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.