comparison lib/bitset/table.c @ 40239:e60e51dd1612

bitset: style changes * lib/bitset/table.c: Use NULL, not 0, for pointers. Formatting changes. (tbitset_list): Reduce scopes.
author Akim Demaille <akim.demaille@gmail.com>
date Thu, 14 Mar 2019 08:31:54 +0100
parents b06060465f09
children d55c6147cb55
comparison
equal deleted inserted replaced
40238:3ac749aa0041 40239:e60e51dd1612
298 { 298 {
299 default: 299 default:
300 abort (); 300 abort ();
301 301
302 case EBITSET_FIND: 302 case EBITSET_FIND:
303 return 0; 303 return NULL;
304 304
305 case EBITSET_CREATE: 305 case EBITSET_CREATE:
306 if (eindex >= size) 306 if (eindex >= size)
307 tbitset_resize (bset, bindex); 307 tbitset_resize (bset, bindex);
308 308
586 return count; 586 return count;
587 } 587 }
588 588
589 589
590 /* Find list of up to NUM bits set in BSET starting from and including 590 /* Find list of up to NUM bits set in BSET starting from and including
591 *NEXT and store in array LIST. Return with actual number of bits 591 *NEXT and store in array LIST. Return with actual number of bits
592 found and with *NEXT indicating where search stopped. */ 592 found and with *NEXT indicating where search stopped. */
593 static bitset_bindex 593 static bitset_bindex
594 tbitset_list (bitset bset, bitset_bindex *list, 594 tbitset_list (bitset bset, bitset_bindex *list,
595 bitset_bindex num, bitset_bindex *next) 595 bitset_bindex num, bitset_bindex *next)
596 { 596 {
597 if (EBITSET_ZERO_P (bset)) 597 if (EBITSET_ZERO_P (bset))
605 bitset_windex eindex = bitno / EBITSET_ELT_BITS; 605 bitset_windex eindex = bitno / EBITSET_ELT_BITS;
606 606
607 if (bitno % EBITSET_ELT_BITS) 607 if (bitno % EBITSET_ELT_BITS)
608 { 608 {
609 /* We need to start within an element. This is not very common. */ 609 /* We need to start within an element. This is not very common. */
610
611 tbitset_elt *elt = elts[eindex]; 610 tbitset_elt *elt = elts[eindex];
612 if (elt) 611 if (elt)
613 { 612 {
614 bitset_windex woffset;
615 bitset_word *srcp = EBITSET_WORDS (elt); 613 bitset_word *srcp = EBITSET_WORDS (elt);
616 614 bitset_windex woffset = eindex * EBITSET_ELT_WORDS;
617 bitset_windex windex = bitno / BITSET_WORD_BITS; 615
618 woffset = eindex * EBITSET_ELT_WORDS; 616 for (bitset_windex windex = bitno / BITSET_WORD_BITS;
619 617 (windex - woffset) < EBITSET_ELT_WORDS; windex++)
620 for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
621 { 618 {
622 bitset_word word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS); 619 bitset_word word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
623 620
624 for (; word; bitno++) 621 for (; word; bitno++)
625 { 622 {