COMMON: Managed List
|Reported by:||lordhoto||Owned by:||lordhoto|
I got to know that some people are asking for a 'managed' List implementation in a common place. Currently lure and parallaction implement their own ManagedList, so we got some code duplication.
This patch adds support to auto free entries of Common::List, when specified. To achieve this it specializes Common::List for pointers and adds a _autoFree flag for it which can be set via the constructor.
The patch also has some downsides and left to be done things:
- find a nice solution for copying lists via "operator =" or the copy constructor, currently copied lists always use "_autoFree = false" to prevent double frees.
- currently "operator delete" is used and thus the implementation can not be used for allocated arrays as entries.
(maybe it could be added that the user can specify a deletion operator via a template parameter and a function pointer passed via constructor)
There are of course other ways to make Common::List (and also other containers) auto free objects, for example we could implement something like boost::shared_ptr which takes care of freeing the object when no more references are to it exist. This patch is just modelled after the way lure and parallaction are handling it though.
Ticket imported from: #1895703. Ticket imported from: patches/908.