ekiga r7353 - in trunk: . lib/gmref
- From: sfre svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r7353 - in trunk: . lib/gmref
- Date: Sat, 15 Nov 2008 12:56:28 +0000 (UTC)
Author: sfre
Date: Sat Nov 15 12:56:28 2008
New Revision: 7353
URL: http://svn.gnome.org/viewvc/ekiga?rev=7353&view=rev
Log:
Ensure the "refcount" field can only be accessed through gmref_inc/dec
This is to avoid having the refcount modified accidentally somewhere
else. Also rename the "count" field to "refcount" for clarity.
Modified:
trunk/ChangeLog
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 Sat Nov 15 12:56:28 2008
@@ -47,7 +47,7 @@
gmref_inc (GmRefCounted* obj)
{
if (obj != 0)
- obj->count++;
+ obj->refcount++;
}
void
@@ -55,8 +55,8 @@
{
if (obj != 0) {
- obj->count--;
- if (obj->count <= 0)
+ obj->refcount--;
+ if (obj->refcount <= 0)
delete obj;
}
}
Modified: trunk/lib/gmref/gmref.h
==============================================================================
--- trunk/lib/gmref/gmref.h (original)
+++ trunk/lib/gmref/gmref.h Sat Nov 15 12:56:28 2008
@@ -38,15 +38,23 @@
#define __GMREF_H__
/* base class */
-struct GmRefCounted
+class GmRefCounted
{
- GmRefCounted (): count(0)
+public:
+ GmRefCounted (): refcount(0)
{}
virtual ~GmRefCounted ()
{}
- int count;
+ int get_refcount ()
+ { return refcount; }
+
+private:
+ int refcount;
+
+ friend void gmref_inc (GmRefCounted* obj);
+ friend void gmref_dec (GmRefCounted* obj);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]