[gstreamermm] Gst::Iterator: fix memory leak
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm] Gst::Iterator: fix memory leak
- Date: Thu, 22 Sep 2016 19:17:23 +0000 (UTC)
commit 01793fce401786ef2481d54057f304b9ccd0d26a
Author: Marcin Kolny <marcin kolny gmail com>
Date: Thu Sep 22 21:17:05 2016 +0200
Gst::Iterator: fix memory leak
gstreamer/src/iterator.hg | 42 +++++++++++++++++++++---------------------
1 files changed, 21 insertions(+), 21 deletions(-)
---
diff --git a/gstreamer/src/iterator.hg b/gstreamer/src/iterator.hg
index d0a27f9..6f10417 100644
--- a/gstreamer/src/iterator.hg
+++ b/gstreamer/src/iterator.hg
@@ -116,7 +116,7 @@ protected:
IteratorBase<CppType>& operator=(const IteratorBase<CppType>& other);
#ifndef DOXYGEN_SHOULD_SKIP_THIS
- GValue* current; // The current element the iterator is referencing.
+ GValue current; // The current element the iterator is referencing.
IteratorResult current_result; // The current result of a next() call.
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@@ -241,7 +241,7 @@ public:
template<class CppType>
IteratorBase<CppType>::IteratorBase()
-: current(new GValue()),
+: current(G_VALUE_INIT),
current_result(Gst::ITERATOR_OK),
cobject_(0),
take_ownership(true)
@@ -258,7 +258,7 @@ IteratorBase<CppType>::IteratorBase(const IteratorBase<CppType>& other)
template<class CppType>
IteratorBase<CppType>::IteratorBase(GstIterator* castitem, bool take_ownership)
-: current(new GValue()),
+: current(G_VALUE_INIT),
current_result(Gst::ITERATOR_OK),
cobject_(castitem),
take_ownership(take_ownership)
@@ -276,15 +276,15 @@ template<class CppType>
IteratorResult IteratorBase<CppType>::next()
{
// Unset current before calling gst_iterator_next()
- if(G_IS_VALUE(this->current))
- g_value_unset(this->current);
+ if(G_IS_VALUE(¤t))
+ g_value_unset(¤t);
current_result =
- static_cast<Gst::IteratorResult>(gst_iterator_next(cobj(), current));
+ static_cast<Gst::IteratorResult>(gst_iterator_next(cobj(), ¤t));
// Reset current if iterator is done:
if(current_result == Gst::ITERATOR_DONE)
- g_value_reset (current);
+ g_value_reset (¤t);
return current_result;
}
@@ -293,14 +293,14 @@ template<class CppType>
void IteratorBase<CppType>::resync()
{
gst_iterator_resync(cobj());
- g_value_reset (current);
+ g_value_reset (¤t);
current_result = Gst::ITERATOR_OK;
}
template<class CppType>
bool IteratorBase<CppType>::is_start() const
{
- return (G_VALUE_HOLDS_OBJECT(current) && current_result == Gst::ITERATOR_OK);
+ return (G_VALUE_HOLDS_OBJECT(¤t) && current_result == Gst::ITERATOR_OK);
}
template<class CppType>
@@ -312,7 +312,7 @@ bool IteratorBase<CppType>::is_end() const
template<class CppType>
IteratorBase<CppType>::operator bool() const
{
- return (! G_VALUE_HOLDS_OBJECT(current));
+ return (! G_VALUE_HOLDS_OBJECT(¤t));
}
template<class CppType>
@@ -328,8 +328,8 @@ void IteratorBase<CppType>::swap(IteratorBase<CppType>& other)
GValue temp_current = G_VALUE_INIT;
g_value_init(&temp_current, G_VALUE_TYPE(current));
- g_value_copy(current, &temp_current);
- g_value_copy(other.current, current);
+ g_value_copy(¤t, &temp_current);
+ g_value_copy(other.current, ¤t);
g_value_copy(&temp_current, other.current);
const IteratorResult temp_result = current_result;
@@ -346,8 +346,8 @@ IteratorBase<CppType>::~IteratorBase()
gst_iterator_free(cobject_);
cobject_ = nullptr;
}
- if(G_IS_VALUE(this->current))
- g_value_unset(this->current);
+ if(G_IS_VALUE(¤t))
+ g_value_unset(¤t);
}
/***************** Gst::IteratorBasic<CppType> ***********************/
@@ -375,8 +375,8 @@ CppType IteratorBasic<CppType>::operator*() const
{
typedef typename CppType::BaseObjectType CType;
- if(G_IS_VALUE(this->current))
- return CppType(static_cast<CType*>(g_value_get_object(this->current)));
+ if(G_IS_VALUE(&this->current))
+ return CppType(static_cast<CType*>(g_value_get_object(&this->current)));
else
return CppType();
}
@@ -386,7 +386,7 @@ CppType* IteratorBasic<CppType>::operator->() const
{
static typename CppType::CppObjectType result;
- if(G_IS_VALUE(this->current))
+ if(G_IS_VALUE(&this->current))
{
result = this->operator*();
return &result;
@@ -442,11 +442,11 @@ Glib::RefPtr<CppType> Iterator<CppType>::operator*() const
{
typedef typename CppType::BaseObjectType CType;
- if(G_IS_VALUE(this->current))
+ if(G_IS_VALUE(&this->current))
{
//Take extra reference when dereferencing. The reference will disappear
//when Glib::RefPtr<> is destroyed.
- return Glib::wrap(static_cast<CType*>(g_value_get_object (this->current)), true);
+ return Glib::wrap(static_cast<CType*>(g_value_get_object (&this->current)), true);
}
else
return Glib::RefPtr<CppType>(0);
@@ -457,11 +457,11 @@ CppType* Iterator<CppType>::operator->() const
{
typedef typename CppType::BaseObjectType CType;
- if(G_IS_VALUE(this->current))
+ if(G_IS_VALUE(&this->current))
{
//Take extra reference when dereferencing. The reference will disappear
//when Glib::RefPtr<> is destroyed.
- return Glib::wrap(static_cast<CType*>(g_value_get_object (this->current)), true).operator->();
+ return Glib::wrap(static_cast<CType*>(g_value_get_object (&this->current)), true).operator->();
}
else
return static_cast<CppType*>(0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]