Move object to last position in list
BlitzMax Forums/BlitzMax Programming/Move object to last position in list I have tried many ways and RemoveLink doenst seem to remove the object, thus creating a mem leak.
But 'CurrentGUI.WindowList.Remove Win' does remove it, and If I add it to the list then I also get mem leak :/
But 'CurrentGUI.WindowList.Remove Win' does remove it, and If I add it to the list then I also get mem leak :/
ListRemove mylist,obj
ListAddLast mylist,obj
just removing it and adding it will put it on the end.
ListAddLast mylist,obj
just removing it and adding it will put it on the end.
It's probably not a memory leak. It has to do with the way memory is handled in Max.
When you free an object the memory is flagged as available the next time you call flushmem(), but it isn't given back to the system. If you call remove() and then AddLast() without flushing the memory in between new memory will be allocated becaus the old memory is still considered occupied.
Look at http://www.blitzwiki.org/index.php/FlushMem
When you free an object the memory is flagged as available the next time you call flushmem(), but it isn't given back to the system. If you call remove() and then AddLast() without flushing the memory in between new memory will be allocated becaus the old memory is still considered occupied.
Look at http://www.blitzwiki.org/index.php/FlushMem
an alternative, and this may not be what you need, is to override the compare method on the types you are storing. return -1 for less than, 0 for equal, and 1 for greater than. then all you need to do is change on the instance of the type whatever the compare is using to base its values on and then call the sort method of the TList instance.