| 235 | */ |
| 236 | |
| 237 | LIST * list_pop_front( LIST * l ) |
| 238 | { |
| 239 | unsigned size = list_length( l ); |
| 240 | assert( size ); |
| 241 | --size; |
| 242 | object_free( list_front( l ) ); |
| 243 | |
| 244 | if ( size == 0 ) |
| 245 | { |
| 246 | list_dealloc( l ); |
| 247 | return L0; |
| 248 | } |
| 249 | |
| 250 | if ( ( ( size - 1 ) & size ) == 0 ) |
| 251 | { |
| 252 | LIST * const nl = list_alloc( size ); |
| 253 | nl->impl.size = size; |
| 254 | memcpy( list_begin( nl ), list_begin( l ) + 1, size * sizeof( OBJECT * ) |
| 255 | ); |
| 256 | list_dealloc( l ); |
| 257 | return nl; |
| 258 | } |
| 259 | |
| 260 | l->impl.size = size; |
| 261 | memmove( list_begin( l ), list_begin( l ) + 1, size * sizeof( OBJECT * ) ); |
| 262 | return l; |
| 263 | } |
| 264 | |
| 265 | LIST * list_reverse( LIST * l ) |
| 266 | { |
no test coverage detected