From 926e086550c525ae9cd07f7521e9c524ca9db607 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 17 Jun 2017 21:25:37 +0300 Subject: [PATCH] Fix segmentation fault --- XS.xs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; } } -- 2.30.2