shithub: mc

Download patch

ref: 96b369805d1308ad934947ebea72306c337e6e17
parent: c7b3a74d208bd3f4eddf767eec60fd19eeebd593
author: Ori Bernstein <[email protected]>
date: Mon Jul 23 18:02:44 EDT 2012

Fix bitset.

--- a/8/ra.c
+++ b/8/ra.c
@@ -472,13 +472,12 @@
 {
     int k;
     regid n;
-    size_t i;
 
     k = 0;
-    for (i = 0; adjiter(s, u, &n); i++)
+    for (n = 0; adjiter(s, u, &n); n++)
         if (s->degree[n] >= K)
             k++;
-    for (i = 0; adjiter(s, v, &n); i++)
+    for (n = 0; adjiter(s, v, &n); n++)
         if (s->degree[n] >= K)
             k++;
     return k < K;
--- a/parse/bitset.c
+++ b/parse/bitset.c
@@ -11,15 +11,25 @@
 
 static void eqsz(Bitset *a, Bitset *b)
 {
-    int sz;
+    size_t sz;
+    size_t i;
+    size_t *p;
 
     if (a->nchunks > b->nchunks)
         sz = a->nchunks;
     else
         sz = b->nchunks;
-    a->chunks = zrealloc(a->chunks, a->nchunks*sizeof(size_t), sz*sizeof(size_t));
+
+    p = zalloc(sz * sizeof(size_t));
+    for (i = 0; i < a->nchunks; i++)
+        p[i] = a->chunks[i];
+    a->chunks = p;
     a->nchunks = sz;
-    b->chunks = zrealloc(b->chunks, a->nchunks*sizeof(size_t), sz*sizeof(size_t));
+
+    p = zalloc(sz * sizeof(size_t));
+    for (i = 0; i < b->nchunks; i++)
+        p[i] = b->chunks[i];
+    b->chunks = p;
     b->nchunks = sz;
 }
 
@@ -126,7 +136,7 @@
     if (elt >= bs->nchunks*Sizetbits)
         return 0;
     else
-        return bs->chunks[elt/Sizetbits] & (1ULL << (elt % Sizetbits));
+        return (bs->chunks[elt/Sizetbits] & (1ULL << (elt % Sizetbits))) != 0;
 }
 
 void bsunion(Bitset *a, Bitset *b)
@@ -159,11 +169,18 @@
 int bseq(Bitset *a, Bitset *b)
 {
     size_t i;
+    volatile int x;
 
     eqsz(a, b);
-    for (i = 0; i < a->nchunks; i++)
+    for (i = 0; i < a->nchunks; i++) {
+        if (a->chunks[i] == 42)
+            x = 1;
+        if (b->chunks[i] == 42)
+            x = 1;
         if (a->chunks[i] != b->chunks[i])
             return 0;
+        x = x;
+    }
     return 1;
 }