| 58 | */ |
| 59 | |
| 60 | LIST * list_append( LIST * l, LIST * nl ) |
| 61 | { |
| 62 | if ( list_empty( l ) ) |
| 63 | return nl; |
| 64 | if ( !list_empty( nl ) ) |
| 65 | { |
| 66 | int const l_size = list_length( l ); |
| 67 | int const nl_size = list_length( nl ); |
| 68 | int const size = l_size + nl_size; |
| 69 | unsigned const bucket = get_bucket( size ); |
| 70 | |
| 71 | /* Do we need to reallocate? */ |
| 72 | if ( l_size <= ( 1u << ( bucket - 1 ) ) ) |
| 73 | { |
| 74 | LIST * result = list_alloc( size ); |
| 75 | memcpy( list_begin( result ), list_begin( l ), l_size * sizeof( |
| 76 | OBJECT * ) ); |
| 77 | list_dealloc( l ); |
| 78 | l = result; |
| 79 | } |
| 80 | |
| 81 | l->impl.size = size; |
| 82 | memcpy( list_begin( l ) + l_size, list_begin( nl ), nl_size * sizeof( |
| 83 | OBJECT * ) ); |
| 84 | list_dealloc( nl ); |
| 85 | } |
| 86 | return l; |
| 87 | } |
| 88 | |
| 89 | LISTITER list_begin( LIST * l ) |
| 90 | { |
no test coverage detected