[fpc-pascal] For ..in GetEnumerator Allocation

Ryan Joseph ryan at thealchemistguild.com
Wed Oct 4 17:12:30 CEST 2017

> On Oct 4, 2017, at 10:03 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
> Newinstance allocates the memory for a new instance of the class.
> By default this is GetMem(instanceSize).

So you override the class method Newinstance in the enumerator class and return the same block of memory? Then when I override FreeInstance and do nothing I need to manually free the memory in the calling class I guess.

That’s an interesting solution and I didn’t know TObject did that even but using records still seems like a better solution and about as efficient (perhaps). I’ll try this tomorrow also to make sure I understand it. Thanks.

	Ryan Joseph

More information about the fpc-pascal mailing list