changeset 16428:728b4288c061

The compiler is really smart enough to catch this, but let's make it explicit.
author Ethan Blanton <elb@pidgin.im>
date Wed, 25 Apr 2007 23:36:19 +0000
parents 50380e48fb65
children f9597f375b07
files libpurple/plugins/tcl/tcl_ref.c
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/plugins/tcl/tcl_ref.c	Wed Apr 25 21:49:37 2007 +0000
+++ b/libpurple/plugins/tcl/tcl_ref.c	Wed Apr 25 23:36:19 2007 +0000
@@ -114,17 +114,18 @@
 	char *ptr;
 	PurpleStringref *type;
 	void *value;
-	int magicnumber = strlen("purple-");
+	static const char const *prefix = "purple-";
+	static const int prefixlen = sizeof(prefix) - 1;
 
-	if (strlen(bytes) < magicnumber
-	    || strncmp(bytes, "purple-", magicnumber)
+	if (strlen(bytes) < prefixlen
+	    || strncmp(bytes, prefix, prefixlen)
 	    || (ptr = strchr(bytes, ':')) == NULL
-	    || (ptr - bytes) == magicnumber)
+	    || (ptr - bytes) == prefixlen)
 		goto badobject;
 
 	/* Bad Ethan */
 	*ptr = '\0';
-	type = purple_stringref_new(bytes + magicnumber);
+	type = purple_stringref_new(bytes + prefixlen);
 	*ptr = ':';
 	ptr++;