Init array to -1 with memset()?

Wayne Davison wayned at samba.org
Tue Jan 27 17:36:06 GMT 2004


The match.c code has a loop that initializes an array to -1.  I'm
considering changing this to a memset() of 0xFF over all the array's
bytes, but that depends on a system's representation of a -1 being "all
bit on".  Should I be anal about this and add a configure check to make
sure that we're not running on some weird system where this is not true?
Or should I just let this be as it was?

..wayne..
-------------- next part --------------
--- match.c	3 Jan 2004 19:28:03 -0000	1.60
+++ match.c	27 Jan 2004 17:04:22 -0000
@@ -75,8 +75,12 @@ static void build_hash_table(struct sum_
 
 	qsort(targets,s->count,sizeof(targets[0]),(int (*)())compare_targets);
 
+#ifdef WEIRD_MINUS_ONE
 	for (i = 0; i < TABLESIZE; i++)
 		tag_table[i] = NULL_TAG;
+#else
+	memset((char *)tag_table, 0xFF, TABLESIZE * sizeof *tag_table);
+#endif
 
 	for (i = s->count; i-- > 0; )
 		tag_table[targets[i].t] = i;


More information about the rsync mailing list