@@ -501,22 +501,24 @@ void DCV_copy_slice_to(const DeltaChunkVector* src, DeltaChunkVector* dest, ull
501501inline
502502void DCV_replace_one_by_many (const DeltaChunkVector * from , DeltaChunkVector * to , DeltaChunk * at )
503503{
504- fprintf (stderr , "Replace one by many: from->size = %i, to->size = %i, to->reserved = %i\n" , (int )from -> size , (int )to -> size , (int )to -> reserved_size );
504+ // fprintf(stderr, "Replace one by many: from->size = %i, to->size = %i, to->reserved = %i\n", (int)from->size, (int)to->size, (int)to->reserved_size);
505505 assert (from -> size > 1 );
506506 assert (to -> size + from -> size - 1 <= to -> reserved_size );
507507
508508 // -1 because we replace 'at'
509509 DC_destroy (at );
510- to -> size += from -> size - 1 ;
511510
512511 // If we are somewhere in the middle, we have to make some space
513512 if (DCV_last (to ) != at ) {
514- fprintf (stderr , "moving to %p from %p , num bytes = %i\n" , at + from -> size , at + 1 , (int )(( DCV_end (to ) - (at + 1 )) * sizeof ( DeltaChunk )));
515- memmove ((void * )(at + from -> size ), (void * )(at + 1 ), (size_t )(DCV_end (to ) - (at + 1 )) * sizeof (DeltaChunk ));
513+ // fprintf(stderr, "moving to %i from %i , num chunks = %i\n", (int)(( at+from->size)-to->mem), (int)(( at+1)-to->mem) , (int)(DCV_end(to) - (at+1)));
514+ memmove ((void * )(at + from -> size ), (void * )(at + 1 ), (size_t )(( DCV_end (to ) - (at + 1 )) * sizeof (DeltaChunk ) ));
516515 }
517-
516+
518517 // Finally copy all the items in
519518 memcpy ((void * ) at , (void * )from -> mem , from -> size * sizeof (DeltaChunk ));
519+
520+ // FINALLY: update size
521+ to -> size += from -> size - 1 ;
520522}
521523
522524// Take slices of bdcv into the corresponding area of the tdcv, which is the topmost
0 commit comments