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