Mercurial > hg > Applications > Grep
changeset 93:23e796173c91
fix malloc in in BitInfo.bitContainer
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 27 Oct 2015 19:29:26 +0900 |
parents | 9a1bb8f439f5 |
children | 43b807f88961 874cc70386f9 |
files | c/bitVector/main.cc |
diffstat | 1 files changed, 3 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/c/bitVector/main.cc Mon Oct 26 18:36:19 2015 +0900 +++ b/c/bitVector/main.cc Tue Oct 27 19:29:26 2015 +0900 @@ -16,9 +16,10 @@ printf("Array Num : %d\n",bi->arrayNum); - unsigned long bitContainer[bi->arrayNum]; + bi->bitContainer = (unsigned long*)malloc(sizeof(unsigned long)*bi->arrayNum); + for (int i = 0; i < bi->arrayNum; i++) { - bitContainer[i] = 0; + bi->bitContainer[i] = 0; } unsigned long tmp = 1; int arrayPosition = 0; @@ -26,13 +27,9 @@ arrayPosition = bitSetPosition / bitBlock; bitSetPosition = bitSetPosition % bitBlock; - - bi->bitContainer = bitContainer; tmp = tmp << (bitBlock - 1 - bitSetPosition); bi->bitContainer[arrayPosition] = bi->bitContainer[arrayPosition] | tmp; - bitPrint(bi); - return bi; }