From 41dcbac5ea09640c7bdbb77b033fa9446d0578cd Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 29 Apr 2025 11:36:28 -0400 Subject: [PATCH] MT#62181 hash_table: obsolete allocator This was probably intended as a helper to facilitate reference counted pointers, but this isn't used anywhere, and the only "allocator" in use is the default wrapper around `delete`. If reference counted pointers are ever relevant, they can be done using a shared_ptr. Change-Id: I2adb561b76efcaf5fb119939f25a7c2438196a5b --- core/hash_table.h | 21 +++------------------ core/sip/tr_blacklist.cpp | 2 +- core/sip/tr_blacklist.h | 1 - 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/core/hash_table.h b/core/hash_table.h index 9792af30..b5c24b33 100644 --- a/core/hash_table.h +++ b/core/hash_table.h @@ -123,26 +123,12 @@ protected: value_list elmts; }; -template -class ht_delete -{ -public: - Value* new_elmt(Value* v) { - return v; - } - void dispose(Value* v) { - delete v; - } -}; - -template, +template > class ht_map_bucket: public AmMutex { public: typedef map value_map; - typedef ElmtAlloc allocator; ht_map_bucket(unsigned long id) : id(id) {} virtual ~ht_map_bucket() {} @@ -167,9 +153,8 @@ public: * Insert the value into this bucket. */ virtual bool insert(const Key& k, Value* v) { - v = ElmtAlloc().new_elmt(v); bool res = elmts.insert(typename value_map::value_type(k,v)).second; - if(!res) ElmtAlloc().dispose(v); + if(!res) delete v; return res; } @@ -183,7 +168,7 @@ public: if(it != elmts.end()){ Value* v = it->second; elmts.erase(it); - ElmtAlloc().dispose(v); + delete v; return true; } return false; diff --git a/core/sip/tr_blacklist.cpp b/core/sip/tr_blacklist.cpp index e79223bc..53563be6 100644 --- a/core/sip/tr_blacklist.cpp +++ b/core/sip/tr_blacklist.cpp @@ -75,7 +75,7 @@ bool blacklist_bucket::remove(const bl_addr& addr) bl_entry* v = it->second; wheeltimer::instance()->remove_timer(v->t); elmts.erase(it); - allocator().dispose(v); + delete v; return true; } diff --git a/core/sip/tr_blacklist.h b/core/sip/tr_blacklist.h index d30f09a3..1f3a1dd7 100644 --- a/core/sip/tr_blacklist.h +++ b/core/sip/tr_blacklist.h @@ -27,7 +27,6 @@ struct bl_addr_less struct bl_entry; typedef ht_map_bucket, bl_addr_less> bl_bucket_base; class blacklist_bucket