diff src/stringref.c @ 7795:069ee4ecb56a

[gaim-migrate @ 8441] Everybody likes a good macro! committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Sun, 07 Dec 2003 20:44:07 +0000
parents c2e391c480b6
children e04c0044c56f
line wrap: on
line diff
--- a/src/stringref.c	Sun Dec 07 20:21:15 2003 +0000
+++ b/src/stringref.c	Sun Dec 07 20:44:07 2003 +0000
@@ -30,6 +30,8 @@
 #include "debug.h"
 #include "stringref.h"
 
+#define REFCOUNT(x) ((x) & 0x7fffffff)
+
 static GList *gclist = NULL;
 
 static void stringref_free(GaimStringref *stringref);
@@ -96,7 +98,7 @@
 {
 	if (stringref == NULL)
 		return;
-	if ((--(stringref->ref) & 0x7fffffff) == 0) {
+	if (REFCOUNT(--(stringref->ref)) == 0) {
 		if (stringref->ref & 0x80000000)
 			gclist = g_list_remove(gclist, stringref);
 		stringref_free(stringref);
@@ -121,7 +123,7 @@
 static void stringref_free(GaimStringref *stringref)
 {
 #ifdef DEBUG
-	if (stringref->ref != 0) {
+	if (REFCOUNT(stringref->ref) != 0) {
 		gaim_debug(GAIM_DEBUG_ERROR, "stringref", "Free of nonzero (%d) ref stringref!\n", stringref->ref);
 		return;
 	}
@@ -136,8 +138,7 @@
 
 	while (gclist != NULL) {
 		ref = gclist->data;
-		ref->ref &= 0x7fffffff;
-		if (ref->ref == 0) {
+		if (REFCOUNT(ref->ref) == 0) {
 			stringref_free(ref);
 		}
 		del = gclist;