pidgin: 034300b3: Elliott's code looks nicer.

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sat Jul 4 20:10:29 EDT 2009


-----------------------------------------------------------------
Revision: 034300b33708a7dbb7856d91c3098493b2dffa34
Ancestor: 918f0b3e778a60c2fdae99667076006059a193d3
Author: darkrain42 at pidgin.im
Date: 2009-07-05T00:07:03
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/034300b33708a7dbb7856d91c3098493b2dffa34

Modified files:
        libpurple/cipher.c

ChangeLog: 

Elliott's code looks nicer.

-------------- next part --------------
============================================================
--- libpurple/cipher.c	cd471d079160276a9b6998b35a1108299d08ee19
+++ libpurple/cipher.c	10bafb597e824bff2acd6f634db65eea6e36764e
@@ -108,21 +108,13 @@ purple_g_checksum_append(PurpleCipherCon
 	checksum = purple_cipher_context_get_data(context);
 	g_return_if_fail(checksum != NULL);
 
-	if (len > (gsize)G_MAXSSIZE) {
-		/*
-		 * g_checksum_update takes a gssize, whereas we handle gsizes. To
-		 * be pedantically correct, we need to handle this case. In real life,
-		 * I think this couldn't actually occur.
-		 */
-		const guchar *buf = data;
-		gssize chunk_size;
-		while (len > 0) {
-			chunk_size = MIN(G_MAXSSIZE, len);
-			g_checksum_update(checksum, buf, chunk_size);
-			len -= chunk_size;
-			buf += chunk_size;
-		}
-	} else
+	while (len >= G_MAXSSIZE) {
+		g_checksum_update(checksum, data, G_MAXSSIZE);
+		len -= G_MAXSSIZE;
+		data += G_MAXSSIZE;
+	}
+
+	if (len)
 		g_checksum_update(checksum, data, len);
 }
 


More information about the Commits mailing list