X-Git-Url: https://ginac.de/CLN/cln.git//cln.git?a=blobdiff_plain;ds=sidebyside;f=src%2Fbase%2Fhash%2Fcl_hash2weak.h;h=5a2db4515516491287e3e7182dd19df250c387ae;hb=5370ad8054201cf23d4f94a52f4d3f7f9f3cd511;hp=c3c4279aeb3d9901bf764c9cb3de9fa332c1c741;hpb=9220842a1565e6f99cc483d59f042a61aafc5a4e;p=cln.git diff --git a/src/base/hash/cl_hash2weak.h b/src/base/hash/cl_hash2weak.h index c3c4279..5a2db45 100644 --- a/src/base/hash/cl_hash2weak.h +++ b/src/base/hash/cl_hash2weak.h @@ -27,9 +27,9 @@ struct cl_heap_weak_hashtable_2 : public cl_heap_hashtable_2 &); + bool (* const _maygc_htentry) (const cl_htentry2&); // Constructor. - cl_heap_weak_hashtable_2 (cl_boolean (*maygc_htentry) (const cl_htentry2&)) + cl_heap_weak_hashtable_2 (bool (*maygc_htentry) (const cl_htentry2&)) : cl_heap_hashtable_2 (), _maygc_htentry (maygc_htentry) { @@ -39,14 +39,14 @@ private: // Garbage collection. // Before growing the table, we check whether we can remove unused // entries. - static cl_boolean garcol (cl_heap* _ht) + static bool garcol (cl_heap* _ht) { var cl_heap_weak_hashtable_2* ht = (cl_heap_weak_hashtable_2*)_ht; // Now ht->_garcol_fun = garcol. // It is not worth doing a garbage collection if the table // is small, say, has fewer than 100 entries. if (ht->_count < 100) - return cl_false; + return false; // Do a garbage collection. var long removed = 0; for (long i = 0; i < ht->_size; i++) @@ -63,7 +63,7 @@ private: ht->remove(entry.key1,entry.key2); if (entry.val.pointer_p()) { var cl_heap* p = entry.val.heappointer; - if (!(--p->refcount == 0)) cl_abort(); + if (!(--p->refcount == 0)) throw runtime_exception(); cl_free_heap_object(p); } removed++; @@ -71,24 +71,24 @@ private: } if (removed == 0) // Unsuccessful. Let the table grow immediately. - return cl_false; + return false; else if (2*removed < ht->_count) { // Table shrank by less than a factor of 1/1.5. // Don't expand the table now, but expand it next time. ht->_garcol_fun = garcol_nexttime; - return cl_true; + return true; } else { // Table shrank much. Don't expand the table now, // and try a GC next time. - return cl_true; + return true; } } - static cl_boolean garcol_nexttime (cl_heap* _ht) + static bool garcol_nexttime (cl_heap* _ht) { var cl_heap_weak_hashtable_2* ht = (cl_heap_weak_hashtable_2*)_ht; // Now ht->_garcol_fun = garcol_nexttime. ht->_garcol_fun = cl_heap_weak_hashtable_2::garcol; - return cl_false; + return false; } };