This commit is contained in:
Gregory Burd 2024-04-30 10:51:23 -04:00
parent b399e8af78
commit 9a6ea9519a

View file

@ -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);