From f129c2cc63e4fdd7ea1be5295e3ed46f8ed4cb04 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Thu, 30 Dec 2010 22:35:16 -0800 Subject: [PATCH] Thanks to Yootay and branan for figuring out why FastStack crashed. --- FastStack.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/FastStack.h b/FastStack.h index c5463f3..b2dc3df 100644 --- a/FastStack.h +++ b/FastStack.h @@ -24,6 +24,11 @@ public: delete[] m_stack; } + FastStack& operator=(const FastStack& copy) { + replace(copy); + return *this; + } + void push(PycRef node) { m_stack[++m_ptr] = node; } @@ -43,11 +48,15 @@ public: void replace(const FastStack& copy) { - for (int i=0; i<=copy.m_ptr; i++) - m_stack[i] = copy.m_stack[i]; - for (int i=copy.m_ptr+1; i<=m_ptr; i++) - m_stack[i] = Node_NULL; + if (© == this) + return; + delete[] m_stack; + + m_size = copy.m_size; m_ptr = copy.m_ptr; + m_stack = new PycRef[m_size]; + for (int i=0; i<= m_ptr; i++) + m_stack[i] = copy.m_stack[i]; } private: