adding a merge map function #6
1 changed files with 2 additions and 5 deletions
|
@ -1282,15 +1282,12 @@ sparsemap_merge(sparsemap_t *map, sparsemap_t *other)
|
|||
__sm_chunk_t src_chunk;
|
||||
__sm_chunk_map_init(&src_chunk, src + sizeof(sm_idx_t));
|
||||
size_t src_size = __sm_chunk_map_get_size(&src_chunk);
|
||||
uint8_t buf[sizeof(sm_idx_t) + sizeof(sm_bitvec_t) * 2] = { 0 };
|
||||
if (dst_count == 0) {
|
||||
__sm_append_data(map, &buf[0], sizeof(buf));
|
||||
__sm_append_data(map, src, sizeof(sm_idx_t) + src_size);
|
||||
} else {
|
||||
size_t offset = __sm_get_chunk_map_offset(map, dst_start);
|
||||
__sm_insert_data(map, offset, &buf[0], sizeof(buf));
|
||||
__sm_insert_data(map, offset, src, sizeof(sm_idx_t) + src_size);
|
||||
}
|
||||
memcpy(dst + sizeof(sm_idx_t), &src_chunk, src_size);
|
||||
*(sm_idx_t *)dst = src_start;
|
||||
|
||||
/* Update the chunk count and data_used. */
|
||||
__sm_set_chunk_map_count(map, __sm_get_chunk_map_count(map) + 1);
|
||||
|
|
Loading…
Reference in a new issue