Mercurial > ~dholland > hg > tradcpp > index.cgi
comparison macro.c @ 74:bbbf71859a21
fix stupid bugs
author | David A. Holland |
---|---|
date | Mon, 10 Jun 2013 18:49:36 -0400 |
parents | 2e25e55dba6b |
children | 7e4723d34248 |
comparison
equal
deleted
inserted
replaced
73:d122b4553150 | 74:bbbf71859a21 |
---|---|
353 numbuckets = macroarrayarray_num(¯os); | 353 numbuckets = macroarrayarray_num(¯os); |
354 macroarrayarray_setsize(¯os, numbuckets*2); | 354 macroarrayarray_setsize(¯os, numbuckets*2); |
355 | 355 |
356 assert(hashmask == numbuckets - 1); | 356 assert(hashmask == numbuckets - 1); |
357 newmask = (hashmask << 1) | 1U; | 357 newmask = (hashmask << 1) | 1U; |
358 tossbit = newmask && ~hashmask; | 358 tossbit = newmask & ~hashmask; |
359 hashmask = newmask; | 359 hashmask = newmask; |
360 | 360 |
361 for (i=0; i<numbuckets; i++) { | 361 for (i=0; i<numbuckets; i++) { |
362 newbucket = NULL; | 362 newbucket = NULL; |
363 oldbucket = macroarrayarray_get(¯os, i); | 363 oldbucket = macroarrayarray_get(¯os, i); |
364 if (oldbucket == NULL) { | |
365 macroarrayarray_set(¯os, numbuckets + i, NULL); | |
366 continue; | |
367 } | |
364 oldnum = macroarray_num(oldbucket); | 368 oldnum = macroarray_num(oldbucket); |
365 for (j=0; j<oldnum; j++) { | 369 for (j=0; j<oldnum; j++) { |
366 m = macroarray_get(oldbucket, j); | 370 m = macroarray_get(oldbucket, j); |
367 if (m->hash & tossbit) { | 371 if (m->hash & tossbit) { |
368 if (newbucket == NULL) { | 372 if (newbucket == NULL) { |
372 macroarray_add(newbucket, m, NULL); | 376 macroarray_add(newbucket, m, NULL); |
373 } | 377 } |
374 } | 378 } |
375 for (j=k=0; j<oldnum; j++) { | 379 for (j=k=0; j<oldnum; j++) { |
376 m = macroarray_get(oldbucket, j); | 380 m = macroarray_get(oldbucket, j); |
377 if (m != NULL && k < j) { | 381 if (m != NULL) { |
378 macroarray_set(oldbucket, k++, m); | 382 if (k < j) { |
383 macroarray_set(oldbucket, k, m); | |
384 } | |
385 k++; | |
379 } | 386 } |
380 } | 387 } |
381 macroarray_setsize(oldbucket, k); | 388 macroarray_setsize(oldbucket, k); |
382 macroarrayarray_set(¯os, numbuckets + i, newbucket); | 389 macroarrayarray_set(¯os, numbuckets + i, newbucket); |
383 } | 390 } |