]> www.ginac.de Git - cln.git/blobdiff - src/base/hash/cl_hash.h
Replace CL_REQUIRE/CL_PROVIDE(cl_symbol) with portable code.
[cln.git] / src / base / hash / cl_hash.h
index 4b34589141d138e6dd2cd2e5ea51aace23e4e3bb..92fbe8be334cfa4593ca367cd97e1fe30aa87df2 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "cln/object.h"
 #include "cln/malloc.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
 #include "cl_iterator.h"
 
 namespace cln {
@@ -17,7 +17,7 @@ template <class htentry> struct _cl_hashtable_iterator;
 
 template <class htentry>
 struct cl_heap_hashtable : public cl_heap {
-       friend struct _cl_hashtable_iterator<htentry>;
+    friend struct _cl_hashtable_iterator<htentry>;
 protected:
     typedef struct htxentry {
         long next;     // > 0: pseudo-list continues at next-1
@@ -33,7 +33,7 @@ protected:
     long * _slots;  // vector of length _modulus
     htxentry * _entries; // vector of length _size
     void* _total_vector;
-    cl_boolean (*_garcol_fun) (cl_heap*); // Function to make room in the table.
+    bool (*_garcol_fun) (cl_heap*); // Function to make room in the table.
                                // Putting some intelligent function here turns
                                // a normal hash table into a "weak" hash table.
 public:
@@ -132,7 +132,7 @@ protected:
             return index;
         }
         #if !(defined(__hppa__) && !defined(__GNUC__)) // workaround HP CC problem
-        cl_abort();
+        throw runtime_exception();
         #endif
         return -1; // dummy
     }
@@ -144,7 +144,7 @@ protected:
     }
 private:
     // Default function to make room in a hash table.
-    static cl_boolean no_garcol (cl_heap* ht) { unused ht; return cl_false; }
+    static bool no_garcol (cl_heap* ht) { unused ht; return false; }
 };
 
 template <class htentry>
@@ -170,7 +170,7 @@ public:
     htentry& next ()
     {
         if (_index < 0)
-            cl_abort();
+            throw runtime_exception();
         var long old_index = _index;
         do { _index--; }
            while (_index >= 0 && _entries[_index].next < 0);
@@ -181,12 +181,7 @@ public:
 template <class htentry>
 inline _cl_hashtable_iterator<htentry> cl_heap_hashtable<htentry>::iterator ()
 {
-#if defined(__GNUC__)
-    return _cl_hashtable_iterator<htentry>::_cl_hashtable_iterator(_entries,_size);
-#else // workaround most C++ compilers' bug
-    typedef _cl_hashtable_iterator<htentry> _cl_hashtable_iterator_type;
-    return _cl_hashtable_iterator_type(_entries,_size);
-#endif
+    return _cl_hashtable_iterator<htentry>(_entries,_size);
 }
 
 }  // namespace cln