changeset 27392:304fef974f28

Elliott's code looks nicer.
author Paul Aurich <paul@darkrain42.org>
date Sun, 05 Jul 2009 00:07:03 +0000
parents 621493e82987
children 319b0f3dd2d0
files libpurple/cipher.c
diffstat 1 files changed, 7 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/cipher.c	Sat Jul 04 23:18:15 2009 +0000
+++ b/libpurple/cipher.c	Sun Jul 05 00:07:03 2009 +0000
@@ -108,21 +108,13 @@
 	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);
 }