From 0409f5b2fa694145aefb136dd6874e2f04ffe6f6 Mon Sep 17 00:00:00 2001
From: Petr Zejdl <petr.zejdl@cern.ch>
Date: Mon, 21 Nov 2022 15:44:18 +0100
Subject: [PATCH] Slice variables are reset when slice is reaused

---
 src/slice.cc | 1 +
 src/slice.h  | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/src/slice.cc b/src/slice.cc
index 8fef1f9b..b61f4f51 100644
--- a/src/slice.cc
+++ b/src/slice.cc
@@ -27,6 +27,7 @@ Slice *Slice::getAllocated(){
   //  fprintf(stderr,"getAllocated called, current size %d\n",free_slices.size());
   Slice::free_slices.pop(t);
   //  fprintf(stderr,"successfully popped, current size %d\n",free_slices.size());
+  t->reset();
   return t;
 }
 
diff --git a/src/slice.h b/src/slice.h
index b7906b3f..438036e4 100644
--- a/src/slice.h
+++ b/src/slice.h
@@ -38,6 +38,13 @@ public:
   static size_t current_queue_size();
   Slice* clone() const { return new Slice(*this); }
 
+  void reset() {
+    logical_end = begin();
+    counts = 0;
+    output = false;
+    firstOrbitN = 0;
+  }
+
   //! Free a Slice object 
   void free() {
     //	fprintf(stderr,"slice free at 0x%llx \n",(unsigned long long) this);
-- 
GitLab