Browse Source

Don't get stuck in an infinite loop on negative integers!

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
7e3527a658
1 changed files with 5 additions and 4 deletions
  1. 5
    4
      src/core/bitops.c

+ 5
- 4
src/core/bitops.c View File

1
 #include <strings.h>
1
 #include <strings.h>
2
 
2
 
3
 int __flsl ( long x ) {
3
 int __flsl ( long x ) {
4
-	int r = 0;
4
+	unsigned long value = x;
5
+	int ls = 0;
5
 
6
 
6
-	for ( r = 0 ; x ; r++ ) {
7
-		x >>= 1;
7
+	for ( ls = 0 ; value ; ls++ ) {
8
+		value >>= 1;
8
 	}
9
 	}
9
-	return r;
10
+	return ls;
10
 }
11
 }

Loading…
Cancel
Save