mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2024-11-10 07:11:54 +00:00
fixed memleak
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@57 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
parent
55ceebf861
commit
d617f066bc
2 changed files with 27 additions and 5 deletions
4
CHANGES
4
CHANGES
|
@ -1,6 +1,10 @@
|
|||
This is the changelog for developers, != changelog for the end user
|
||||
that we distribute with the binaries. (see changelog)
|
||||
|
||||
30/04/2006
|
||||
SPoG
|
||||
- Fixed memory leak in signals library.
|
||||
|
||||
01/04/2006
|
||||
SPoG
|
||||
- Added key-observer interface to entity module API.
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace ListDetail
|
|||
class ListIterator
|
||||
{
|
||||
public:
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef difference_type distance_type;
|
||||
typedef typename Traits::value_type value_type;
|
||||
|
@ -197,6 +197,16 @@ class List : private Allocator
|
|||
typedef ListDetail::ListNode<Value> Node;
|
||||
ListDetail::ListNodeBase list;
|
||||
typedef typename Allocator::template rebind<Node>::other NodeAllocator;
|
||||
|
||||
Node* newNode(const Value& value)
|
||||
{
|
||||
return new (NodeAllocator(*this).allocate(1)) Node(value);
|
||||
}
|
||||
void deleteNode(Node* node)
|
||||
{
|
||||
node->~Node();
|
||||
NodeAllocator(*this).deallocate(node, 1);
|
||||
}
|
||||
public:
|
||||
typedef Value value_type;
|
||||
typedef ListDetail::ListIterator< ListDetail::NonConstTraits<Value> > iterator;
|
||||
|
@ -210,6 +220,15 @@ public:
|
|||
{
|
||||
list_initialise(list);
|
||||
}
|
||||
~List()
|
||||
{
|
||||
for(; list.next != &list;)
|
||||
{
|
||||
Node* node = static_cast<Node*>(list.next);
|
||||
list.next = list.next->next;
|
||||
deleteNode(node);
|
||||
}
|
||||
}
|
||||
iterator begin()
|
||||
{
|
||||
return iterator(static_cast<Node*>(list.next));
|
||||
|
@ -242,9 +261,9 @@ public:
|
|||
{
|
||||
erase(begin(), value);
|
||||
}
|
||||
iterator insert(iterator pos, const Value& x)
|
||||
iterator insert(iterator pos, const Value& value)
|
||||
{
|
||||
Node* node = new (NodeAllocator(*this).allocate(1)) Node(x);
|
||||
Node* node = newNode(value);
|
||||
node_link(node, pos.node());
|
||||
return iterator(node);
|
||||
}
|
||||
|
@ -253,8 +272,7 @@ public:
|
|||
Node* node = pos.node();
|
||||
Node* next = node->getNext();
|
||||
node_unlink(node);
|
||||
node->~Node();
|
||||
NodeAllocator(*this).deallocate(node, 1);
|
||||
deleteNode(node);
|
||||
return iterator(next);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue