pidgin: 5cb44bc3: We don't need to keep the delta in memor...

markdoliner at pidgin.im markdoliner at pidgin.im
Tue Feb 2 18:15:34 EST 2010


-----------------------------------------------------------------
Revision: 5cb44bc3238fe4c7df3f9112833306a80c2df57d
Ancestor: 1863750dfdcf225f01e5ff4ec9e225aa5797269d
Author: markdoliner at pidgin.im
Date: 2010-02-02T23:11:35
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/5cb44bc3238fe4c7df3f9112833306a80c2df57d

Modified files:
        libpurple/protocols/oscar/family_oservice.c
        libpurple/protocols/oscar/oscar.h

ChangeLog: 

We don't need to keep the delta in memory.  We keep the actual time of
the last message.  Saves 20 bytes of memory.

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/family_oservice.c	ff14e58c65ffd5c8273a553a015d2ae605fc1715
+++ libpurple/protocols/oscar/family_oservice.c	c96167552b16b5cbb0a89ea373c885522c9f1aa1
@@ -334,30 +334,16 @@ rateresp(OscarData *od, FlapConnection *
 		rateclass->current = byte_stream_get32(bs);
 		rateclass->max = byte_stream_get32(bs);
 
-		/*
-		 * The server will send an extra five bytes of parameters
-		 * depending on the version we advertised in 1/17.  If we
-		 * didn't send 1/17 (evil!), then this will crash and you
-		 * die, as it will default to the old version but we have
-		 * the new version hardcoded here.
-		 */
-		if (mod->version >= 3)
-		{
-			rateclass->delta = byte_stream_get32(bs);
+		if (mod->version >= 3) {
+			delta = byte_stream_get32(bs);
 			rateclass->dropping_snacs = byte_stream_get8(bs);
-
-			delta = rateclass->delta;
-
-			rateclass->last.tv_sec = now.tv_sec - delta / 1000;
-			delta %= 1000;
-			rateclass->last.tv_usec = now.tv_usec - delta * 1000;
+		} else {
+			delta = 0;
+			rateclass->dropping_snacs = 0;
 		}
-		else
-		{
-			rateclass->delta = rateclass->dropping_snacs = 0;
-			rateclass->last.tv_sec = now.tv_sec;
-			rateclass->last.tv_usec = now.tv_usec;
-		}
+		rateclass->last.tv_sec = now.tv_sec - delta / 1000;
+		delta %= 1000;
+		rateclass->last.tv_usec = now.tv_usec - delta * 1000;
 
 		rateclass->members = g_hash_table_new(g_direct_hash, g_direct_equal);
 		conn->rateclasses = g_slist_prepend(conn->rateclasses, rateclass);
@@ -486,28 +472,21 @@ ratechange(OscarData *od, FlapConnection
 	rateclass->current = byte_stream_get32(bs);
 	rateclass->max = byte_stream_get32(bs);
 
-	if (mod->version >= 3)
-	{
-		rateclass->delta = byte_stream_get32(bs);
+	if (mod->version >= 3) {
+		delta = byte_stream_get32(bs);
 		rateclass->dropping_snacs = byte_stream_get8(bs);
-
-		delta = rateclass->delta;
-
-		rateclass->last.tv_sec = now.tv_sec - delta / 1000;
-		delta %= 1000;
-		rateclass->last.tv_usec = now.tv_usec - delta * 1000;
+	} else {
+		delta = 0;
+		rateclass->dropping_snacs = 0;
 	}
-	else
-	{
-		rateclass->delta = rateclass->dropping_snacs = 0;
-		rateclass->last.tv_sec = now.tv_sec;
-		rateclass->last.tv_usec = now.tv_usec;
-	}
+	rateclass->last.tv_sec = now.tv_sec - delta / 1000;
+	delta %= 1000;
+	rateclass->last.tv_usec = now.tv_usec - delta * 1000;
 
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) {
 		/* Can't pass in guint8 via ... varargs, so we use an unsigned int */
 		unsigned int dropping_snacs = rateclass->dropping_snacs;
-		ret = userfunc(od, conn, frame, code, classid, rateclass->windowsize, rateclass->clear, rateclass->alert, rateclass->limit, rateclass->disconnect, rateclass->current, rateclass->max, rateclass->delta, dropping_snacs);
+		ret = userfunc(od, conn, frame, code, classid, rateclass->windowsize, rateclass->clear, rateclass->alert, rateclass->limit, rateclass->disconnect, rateclass->current, rateclass->max, delta, dropping_snacs);
 	}
 
 	return ret;
============================================================
--- libpurple/protocols/oscar/oscar.h	83790748947a7bba51c3b03577219777753628af
+++ libpurple/protocols/oscar/oscar.h	64005c277e3ac960bb0f1d15a1d8946ce5fadd16
@@ -1685,7 +1685,6 @@ struct rateclass {
 	guint32 disconnect;
 	guint32 current;
 	guint32 max;
-	guint32 delta;
 	guint8 dropping_snacs;
 	GHashTable *members; /* Key is family and subtype, value is TRUE. */
 


More information about the Commits mailing list