]> iEval git - algorithm-bit-xs.git/commitdiff
Fix segmentation fault
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 17 Jun 2017 18:25:37 +0000 (21:25 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 17 Jun 2017 18:25:37 +0000 (21:25 +0300)
XS.xs

diff --git a/XS.xs b/XS.xs
index 940807b509e110ac8e6f9bdf7b32aeccf36d908e..182c51458164d6297b5df83887f5a9b83d697211 100644 (file)
--- a/XS.xs
+++ b/XS.xs
@@ -89,7 +89,7 @@ IV bit2d_query(bit2d *b, IV i1, IV i2) {
        while(i1) {
                i2 = i2c;
                while(i2)
-                       ret += b->t[i1 * b->n + i2], i2 -= i2 & -i2;
+                       ret += b->t[i1 * b->m + i2], i2 -= i2 & -i2;
                i1 -= i1 & -i1;
        }
        return ret;
@@ -108,7 +108,7 @@ void bit2d_update(bit2d *b, IV i1, IV i2, IV value) {
        while(i1 < b->n) {
                i2 = i2c;
                while(i2 < b->m)
-                       b->t[i1 * b->n + i2] += value, i2 += i2 & -i2;
+                       b->t[i1 * b->m + i2] += value, i2 += i2 & -i2;
                i1 += i1 & -i1;
        }
 }
This page took 0.027092 seconds and 4 git commands to generate.