ekiga r7348 - trunk/lib/gmref
- From: jpuydt svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r7348 - trunk/lib/gmref
- Date: Fri, 14 Nov 2008 22:11:12 +0000 (UTC)
Author: jpuydt
Date: Fri Nov 14 22:11:12 2008
New Revision: 7348
URL: http://svn.gnome.org/viewvc/ekiga?rev=7348&view=rev
Log:
Pushed the refcounting in the objects
Modified:
trunk/lib/gmref/gmref.cpp
trunk/lib/gmref/gmref.h
Modified: trunk/lib/gmref/gmref.cpp
==============================================================================
--- trunk/lib/gmref/gmref.cpp (original)
+++ trunk/lib/gmref/gmref.cpp Fri Nov 14 22:11:12 2008
@@ -38,34 +38,25 @@
#include <map>
-static std::map<GmRefCounted*, int> refcounts;
-
void
gmref_init ()
{
- /* the goal is to prevent the static initialization fiasco */
- refcounts.clear ();
}
void
gmref_inc (GmRefCounted* obj)
{
- std::map<GmRefCounted*, int>::iterator iter = refcounts.find (obj);
- if (iter == refcounts.end ()) {
-
- refcounts[obj] = 1;
- } else
- refcounts[obj]++;
+ if (obj != 0)
+ obj->count++;
}
void
gmref_dec (GmRefCounted* obj)
{
- refcounts[obj]--;
-
- if (refcounts[obj] <= 0) {
+ if (obj != 0) {
- refcounts.erase (obj);
- delete obj;
+ obj->count--;
+ if (obj->count <= 0)
+ delete obj;
}
}
Modified: trunk/lib/gmref/gmref.h
==============================================================================
--- trunk/lib/gmref/gmref.h (original)
+++ trunk/lib/gmref/gmref.h Fri Nov 14 22:11:12 2008
@@ -40,8 +40,13 @@
/* base class */
struct GmRefCounted
{
+ GmRefCounted (): count(0)
+ {}
+
virtual ~GmRefCounted ()
{}
+
+ int count;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]