Browse Source

fix reference counting in template data structures

Kolja Strohm 3 years ago
parent
commit
fb79a667f2
3 changed files with 6 additions and 6 deletions
  1. 2 2
      CharMap.h
  2. 2 2
      Pair.h
  3. 2 2
      Tree.h

+ 2 - 2
CharMap.h

@@ -35,7 +35,7 @@ namespace Framework
 
         T *get( unsigned char c )
         {
-            return entries[ (int)c ] ? entries[ (int)c ]->getThis() : 0;
+            return dynamic_cast<T *>( entries[ (int)c ] ? entries[ (int)c ]->getThis() ) : 0;
         }
 
         T *z( unsigned char c )
@@ -59,7 +59,7 @@ namespace Framework
 
         V *getValue()
         {
-            return value ? value->getThis() : 0;
+            return value ? dynamic_cast<V *>( value->getThis() ) : 0;
         }
 
         V *zValue()

+ 2 - 2
Pair.h

@@ -36,7 +36,7 @@ namespace Framework
 
         A *getFirst()
         {
-            return va ? va->getThis() : 0;
+            return va ? dynamic_cast<A *>( va->getThis() ) : 0;
         }
 
         A *zFirst()
@@ -46,7 +46,7 @@ namespace Framework
 
         B *getSecond()
         {
-            return vb ? vb->getThis() : 0;
+            return vb ? dynamic_cast<B *>( vb->getThis() ) : 0;
         }
 
         B *zSecond()

+ 2 - 2
Tree.h

@@ -67,7 +67,7 @@ namespace Framework
 
         T *getValue()
         {
-            return value ? value->getThis() : 0;
+            return value ? dynamic_cast<T *>( value->getThis() ) : 0;
         }
 
         T *zValue()
@@ -77,7 +77,7 @@ namespace Framework
 
         Tree *getParent()
         {
-            return zParent ? zParent->getThis() : 0;
+            return zParent ? dynamic_cast<Tree *>( zParent->getThis() ) : 0;
         }
 
         Tree *zParent()