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
mr13.4
Richard Fuchs 1 year ago
parent 2eb9cf59cc
commit 41dcbac5ea

@ -123,26 +123,12 @@ protected:
value_list elmts;
};
template<class Value>
class ht_delete
{
public:
Value* new_elmt(Value* v) {
return v;
}
void dispose(Value* v) {
delete v;
}
};
template<class Key, class Value,
class ElmtAlloc = ht_delete<Value>,
template<class Key, class Value,
class ElmtCompare = less<Key> >
class ht_map_bucket: public AmMutex
{
public:
typedef map<Key,Value*,ElmtCompare> 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;

@ -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;
}

@ -27,7 +27,6 @@ struct bl_addr_less
struct bl_entry;
typedef ht_map_bucket<bl_addr,bl_entry,
ht_delete<bl_entry>,
bl_addr_less> bl_bucket_base;
class blacklist_bucket

Loading…
Cancel
Save