From: Marius Gavrilescu Date: Sat, 17 Jun 2017 18:25:37 +0000 (+0300) Subject: Fix segmentation fault X-Git-Tag: 0.003~3 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=926e086550c525ae9cd07f7521e9c524ca9db607;hp=34876640088dd67fcc2c05119cab34cc9fa9a777;p=algorithm-bit-xs.git Fix segmentation fault --- diff --git a/XS.xs b/XS.xs index 940807b..182c514 100644 --- 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; } }