@@ -57,7 +57,10 @@ void TSI_init(ToplevelStreamInfo* info)
5757
5858void TSI_destroy (ToplevelStreamInfo * info )
5959{
60+ #ifdef DEBUG
6061 fprintf (stderr , "TSI_destroy: %p\n" , info );
62+ #endif
63+
6164 if (info -> parent_object ){
6265 Py_DECREF (info -> parent_object );
6366 info -> parent_object = 0 ;
@@ -129,6 +132,10 @@ bool TSI_resize(ToplevelStreamInfo* info, uint num_bytes)
129132 if (num_bytes <= info -> tdslen ){
130133 return 1 ;
131134 }
135+
136+ #ifdef DEBUG
137+ fprintf (stderr , "TSI_resize: to %i bytes\n" , num_bytes );
138+ #endif
132139 uint ofs = (uint )(info -> cstart - info -> tds );
133140 info -> tds = PyMem_Realloc ((void * )info -> tds , num_bytes );
134141 info -> tdslen = num_bytes ;
@@ -186,7 +193,6 @@ void DC_apply(const DeltaChunk* dc, const uchar* base, PyObject* writer, PyObjec
186193 assert (0 );
187194 }
188195
189- DC_print (dc , "DC_apply" );
190196
191197 // tuple steals reference, and will take care about the deallocation
192198 PyObject_Call (writer , tmpargs , NULL );
@@ -554,7 +560,6 @@ uint DIV_count_slice_bytes(const DeltaInfoVector* src, uint ofs, uint size)
554560inline
555561uint DIV_copy_slice_to (const DeltaInfoVector * src , uchar * dest , ull tofs , uint size )
556562{
557- fprintf (stderr , "copy slice: ofs = %i, size = %i\n" , (int )tofs , size );
558563 assert (DIV_lbound (src ) <= tofs );
559564 assert ((tofs + size ) <= DIV_info_rbound (src , DIV_last (src )));
560565
@@ -564,10 +569,6 @@ uint DIV_copy_slice_to(const DeltaInfoVector* src, uchar* dest, ull tofs, uint s
564569 DeltaInfo * cdi = DIV_closest_chunk (src , tofs );
565570 uint num_chunks = 0 ;
566571
567- #ifdef DEBUG
568- const uchar * deststart = dest ;
569- #endif
570-
571572 // partial overlap
572573 if (cdi -> to != tofs ) {
573574 const uint relofs = tofs - cdi -> to ;
@@ -592,7 +593,6 @@ uint DIV_copy_slice_to(const DeltaInfoVector* src, uchar* dest, ull tofs, uint s
592593 const DeltaInfo * vecend = DIV_end (src );
593594 for ( ;cdi < vecend ; ++ cdi )
594595 {
595- fprintf (stderr , "copy slice: cdi: to = %i, dso = %i\n" , (int )cdi -> to , (int )cdi -> dso );
596596 num_chunks += 1 ;
597597 next_delta_info (src -> dstream + cdi -> dso , & dc );
598598 if (dc .ts < size ) {
@@ -608,10 +608,6 @@ uint DIV_copy_slice_to(const DeltaInfoVector* src, uchar* dest, ull tofs, uint s
608608 }
609609 }
610610
611- #ifdef DEBUG
612- fprintf (stderr , "copy slice: Wrote %i bytes\n" , (int )(dest - deststart ));
613- #endif
614-
615611 assert (size == 0 );
616612 return num_chunks ;
617613}
@@ -624,7 +620,7 @@ bool DIV_connect_with_base(ToplevelStreamInfo* tsi, DeltaInfoVector* div)
624620 assert (tsi -> num_chunks );
625621
626622 typedef struct {
627- uint bofs ; // byte-offset of delta stream
623+ int bofs ; // byte-offset of delta stream
628624 uint dofs ; // delta stream offset relative to tsi->cstart
629625 } OffsetInfo ;
630626
@@ -635,7 +631,7 @@ bool DIV_connect_with_base(ToplevelStreamInfo* tsi, DeltaInfoVector* div)
635631 }
636632
637633 OffsetInfo * pofs = offset_array ;
638- uint num_addbytes = 0 ;
634+ int num_addbytes = 0 ;
639635 uint dofs = 0 ;
640636
641637 const uchar * data = TSI_first (tsi );
@@ -651,12 +647,10 @@ bool DIV_connect_with_base(ToplevelStreamInfo* tsi, DeltaInfoVector* div)
651647 {
652648 pofs -> bofs = num_addbytes ;
653649 data = next_delta_info (data , & dc );
650+ assert (data );
654651 pofs -> dofs = dofs ;
655652 dofs += (uint )(data - prev_data );
656653
657- fprintf (stderr , "pofs->bofs = %i, ->dofs = %i\n" , pofs -> bofs , pofs -> dofs );
658- DC_print (& dc , "count-run" );
659-
660654 // Data chunks don't need processing
661655 if (dc .data ){
662656 continue ;
@@ -667,7 +661,12 @@ bool DIV_connect_with_base(ToplevelStreamInfo* tsi, DeltaInfoVector* div)
667661 num_addbytes += DIV_count_slice_bytes (div , dc .so , dc .ts ) - (data - prev_data );
668662 }
669663
670- fprintf (stderr , "num_addbytes = %i\n" , num_addbytes );
664+ /*
665+ uint i = 0;
666+ for (; i < tsi->num_chunks; i++){
667+ fprintf(stderr, "%i: bofs: %i, dofs: %i\n", i, offset_array[i].bofs, offset_array[i].dofs);
668+ }
669+ */
671670 assert (DC_rbound (& dc ) == tsi -> target_size );
672671
673672
@@ -695,6 +694,7 @@ bool DIV_connect_with_base(ToplevelStreamInfo* tsi, DeltaInfoVector* div)
695694 // not worth the extra effort
696695 if (cpofs -> bofs ){
697696 memcpy ((void * )(ds + cpofs -> bofs ), (void * )ds , nds - ds );
697+ // memmove((void*)(ds + cpofs->bofs), (void*)ds, nds - ds);
698698 }
699699 continue ;
700700 }
@@ -706,7 +706,6 @@ bool DIV_connect_with_base(ToplevelStreamInfo* tsi, DeltaInfoVector* div)
706706 num_addchunks -= 1 ;
707707 }
708708
709- fprintf (stderr , "num_addchunks = %i\n" , num_addchunks );
710709 tsi -> num_chunks += num_addchunks ;
711710
712711 PyMem_Free (offset_array );
0 commit comments