Recent

Author Topic: is the LIST property from a TFPGList linear?  (Read 375 times)

jamie

  • Hero Member
  • *****
  • Posts: 7705
is the LIST property from a TFPGList linear?
« on: April 22, 2026, 11:20:22 pm »
Using the TFPGLIST  or others VIA the LIST property to gain access to the memory array is this list to be trusted as a linear representation of the entries?
The only true wisdom is knowing you know nothing

Thaddy

  • Hero Member
  • *****
  • Posts: 19156
  • Glad to be alive.
Re: is the LIST property from a TFPGList linear?
« Reply #1 on: April 23, 2026, 12:28:56 pm »
Do you mean the memory layout is consecutive? Yes. Or do you mean it is packed too, i.e. no gaps? No, you have to cater for alignment, because it is a generic solution and the size of a list entry may depend on packing. As standard it is natural alignment. On some platforms, e.g. 16 bit, it is also affected by page size.
Be careful with pointermath in all cases.   It is not for nothing that the list property is documented as "do not use directly"

https://www.freepascal.org/docs-html/rtl/fgl/tfpglist.list.html

If the implementation changes from a Pointer array to a PPointer array you are dead. Currently the list is internally a PByte pointer, but TFPGList may contains classes, which are already pointer types. Or not optimal layed out records.

« Last Edit: April 23, 2026, 12:46:41 pm by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

jamie

  • Hero Member
  • *****
  • Posts: 7705
Re: is the LIST property from a TFPGList linear?
« Reply #2 on: April 23, 2026, 06:17:46 pm »
No
In the constructor.create(owned : boolean = false; adafult : tconstructor = nil)

Otherwise a Tallocator which would be a pointer to the constructor of the class indicated in the < ?????? >
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 7705
Re: is the LIST property from a TFPGList linear?
« Reply #3 on: April 23, 2026, 06:21:42 pm »
I posted to the wrong msg, it should be the orher msg i recently posted
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018