| 277 | } |
| 278 | |
| 279 | int |
| 280 | rangeset_copy(struct rangeset *dst_rs, struct rangeset *src_rs) |
| 281 | { |
| 282 | struct rs_el *src_r, *dst_r; |
| 283 | uint64_t cursor, *r1; |
| 284 | int error; |
| 285 | |
| 286 | MPASS(pctrie_is_empty(&dst_rs->rs_trie)); |
| 287 | rangeset_check(src_rs); |
| 288 | MPASS(dst_rs->rs_dup_data == src_rs->rs_dup_data); |
| 289 | |
| 290 | error = 0; |
| 291 | for (cursor = 0;; cursor = src_r->re_start + 1) { |
| 292 | r1 = pctrie_lookup_ge(&src_rs->rs_trie, cursor); |
| 293 | if (r1 == NULL) |
| 294 | break; |
| 295 | src_r = __containerof(r1, struct rs_el, re_start); |
| 296 | dst_r = dst_rs->rs_dup_data(dst_rs->rs_data_ctx, src_r); |
| 297 | if (dst_r == NULL) { |
| 298 | error = ENOMEM; |
| 299 | break; |
| 300 | } |
| 301 | error = pctrie_insert(&dst_rs->rs_trie, &dst_r->re_start, |
| 302 | rs_node_alloc); |
| 303 | if (error != 0) |
| 304 | break; |
| 305 | } |
| 306 | if (error != 0) |
| 307 | rangeset_remove_all(dst_rs); |
| 308 | return (error); |
| 309 | } |
| 310 | |
| 311 | #ifdef DIAGNOSTIC |
| 312 | static void |
no test coverage detected