diff --git a/src/sparsemap.c b/src/sparsemap.c index 4e2b826..a34ad6c 100644 --- a/src/sparsemap.c +++ b/src/sparsemap.c @@ -1279,29 +1279,12 @@ sparsemap_merge(sparsemap_t *map, sparsemap_t *other) if (src_start < dst_start || dst_count == 0) { __sm_chunk_t src_chunk; __sm_chunk_map_init(&src_chunk, src + sizeof(sm_idx_t)); - uint8_t buf[sizeof(sm_idx_t) + sizeof(sm_bitvec_t) * 2] = { 0 }; size_t src_size = __sm_chunk_map_get_size(&src_chunk); - size_t offset = src_start + (sizeof(sm_idx_t) + src_size); - __sm_insert_data(map, offset, &buf[0], sizeof(buf)); + __sm_insert_data(map, src_start, src, src_size); *(sm_idx_t *)dst = src_start; - __sm_chunk_t dst_chunk; - __sm_chunk_map_init(&dst_chunk, dst + sizeof(sm_idx_t)); - /* Update the chunk count and data_used. */ __sm_set_chunk_map_count(map, __sm_get_chunk_map_count(map) + 1); - if (other->m_data_used != 0) { - other->m_data_used += sizeof(sm_idx_t) + sizeof(sm_bitvec_t); - } - size_t capacity = __sm_chunk_map_get_capacity(&src_chunk); - - /* Reduce the capacity of the source-chunk map. */ - __sm_chunk_map_set_capacity(&dst_chunk, offset % capacity); - - /* - uint8_t *src_data = __sm_get_chunk_map_data(other, src_start); - memcpy(&buf, src_data, src_size); - */ /* Carry on to the next chunk. */ src += sizeof(sm_idx_t) + __sm_chunk_map_get_size(&src_chunk);