Mercurial > ~dholland > hg > tradcpp > index.cgi
diff macro.c @ 74:bbbf71859a21
fix stupid bugs
author | David A. Holland |
---|---|
date | Mon, 10 Jun 2013 18:49:36 -0400 |
parents | 2e25e55dba6b |
children | 7e4723d34248 |
line wrap: on
line diff
--- a/macro.c Mon Jun 10 18:40:26 2013 -0400 +++ b/macro.c Mon Jun 10 18:49:36 2013 -0400 @@ -355,12 +355,16 @@ assert(hashmask == numbuckets - 1); newmask = (hashmask << 1) | 1U; - tossbit = newmask && ~hashmask; + tossbit = newmask & ~hashmask; hashmask = newmask; for (i=0; i<numbuckets; i++) { newbucket = NULL; oldbucket = macroarrayarray_get(¯os, i); + if (oldbucket == NULL) { + macroarrayarray_set(¯os, numbuckets + i, NULL); + continue; + } oldnum = macroarray_num(oldbucket); for (j=0; j<oldnum; j++) { m = macroarray_get(oldbucket, j); @@ -374,8 +378,11 @@ } for (j=k=0; j<oldnum; j++) { m = macroarray_get(oldbucket, j); - if (m != NULL && k < j) { - macroarray_set(oldbucket, k++, m); + if (m != NULL) { + if (k < j) { + macroarray_set(oldbucket, k, m); + } + k++; } } macroarray_setsize(oldbucket, k);