[fpc-pascal] TFPHashList help

Michael Van Canneyt michael at freepascal.org
Tue Oct 3 10:54:40 CEST 2006



On Tue, 3 Oct 2006, Graeme Geldenhuys wrote:

> Hi,
> 
> I have the following class and function that retrieves a object from a
> internal TFPHashList. If the object isn't in the list, it is read from
> a database, and then also inserted into the hashlist, before it gets
> returned.
> 
> Does TFPHashTable also manage the objects it contains (or references)
> like TObjectList.  If not (which I think it doesn't), that means when
> TModuleFlyweightFactory gets destroyed, I need to free and empty the
> internal TFPHashTable as well.  I'm not sure how I would to that
> though.  Can is loop through the hashtable using the Items[] property
> to free off the referenced object. Set that same Item to nil, and then
> in the end, just .Free the FPHashTable?

Well, I just programmed an extension to TFPHashTable (in cooperation with
Dean Zobec) which allows you to select this behaviour: to free or not to free. 

It's not yet in SVN, but if you want I can send it to you.

Michael.



More information about the fpc-pascal mailing list