Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/containers.hfa

    r3381ed7 r768bd556  
    146146        static inline forall( dtype T | is_node(T) ) {
    147147                void ?{}( __queue(T) & this ) with( this ) {
    148                         head{ 1p };
     148                        head{ 0p };
    149149                        tail{ &head };
    150                         verify(*tail == 1p);
    151150                }
    152151
    153152                void append( __queue(T) & this, T * val ) with( this ) {
    154153                        verify(tail != 0p);
    155                         verify(*tail == 1p);
    156154                        *tail = val;
    157155                        tail = &get_next( *val );
    158                         *tail = 1p;
    159156                }
    160157
    161158                T * pop_head( __queue(T) & this ) {
    162                         verify(*this.tail == 1p);
    163159                        T * head = this.head;
    164                         if( head != 1p ) {
     160                        if( head ) {
    165161                                this.head = get_next( *head );
    166                                 if( get_next( *head ) == 1p ) {
     162                                if( !get_next( *head ) ) {
    167163                                        this.tail = &this.head;
    168164                                }
    169165                                get_next( *head ) = 0p;
    170                                 verify(*this.tail == 1p);
    171                                 return head;
    172                         }
    173                         verify(*this.tail == 1p);
    174                         return 0p;
     166                        }
     167                        return head;
    175168                }
    176169
     
    187180                        get_next( *val ) = 0p;
    188181
    189                         verify( (head == 1p) == (&head == tail) );
    190                         verify( *tail == 1p );
     182                        verify( (head == 0p) == (&head == tail) );
     183                        verify( *tail == 0p );
    191184                        return val;
    192185                }
Note: See TracChangeset for help on using the changeset viewer.