I am writing a series of 'classic' datastructures (LinkedList, Stack, Queue etc.) for delphi that I intend to post to DSP for all to use.
I am fisrtly attempting the linked list by inheriting TList and overiding the delete, Clear, and Destroy methods to free any list items that are taken from the list. I am overriding remove as a function which returns a pointer to the removed item.
It seemed a very simple task and it works fine so long as you only use the list to store decendants of TObject. (so that the .free can be used)
A also want to be able to store the basic types such as integer, boolean etc. In these cases there is no free method and typcasting the pointer to Tobject gives an access violation.
What I am trying to do is to find out if the pointer can be cast as a tobject then free it otherwise don't
I have tried casting the pointer as a variant and then getting the varType but it is giving inconsistent results.
Is this possible? I suspect that this may be why Tlist doesn't free up it's resources.
I have delphi 2.01