diff --git a/src/factory/FieldCreateFactory.cpp b/src/factory/FieldCreateFactory.cpp index e0866e7..b5e3d46 100644 --- a/src/factory/FieldCreateFactory.cpp +++ b/src/factory/FieldCreateFactory.cpp @@ -38,24 +38,26 @@ size_t Field::num_instances; struct Field::Helper { - static void hash(Field *fld) { + static unsigned hash(Field *fld) { std::ostringstream key; // hash the output of operator<<() // not efficient, but stable within this process. key<<(*fld); - fld->m_hash = epicsStrHash(key.str().c_str(), 0xbadc0de1); + unsigned H = epicsStrHash(key.str().c_str(), 0xbadc0de1); + fld->m_hash = H; + return H; } }; struct FieldCreate::Helper { template static void cache(const FieldCreate *create, std::tr1::shared_ptr& ent) { - Field::Helper::hash(ent.get()); + unsigned hash = Field::Helper::hash(ent.get()); Lock G(create->mutex); // we examine raw pointers stored in create->cache, which is safe under create->mutex - std::pair itp(create->cache.equal_range(ent->m_hash)); + std::pair itp(create->cache.equal_range(hash)); for(; itp.first!=itp.second; ++itp.first) { Field* cent(itp.first->second); FLD* centx(dynamic_cast(cent)); @@ -72,7 +74,7 @@ struct FieldCreate::Helper { } } - create->cache.insert(std::make_pair(ent->m_hash, ent.get())); + create->cache.insert(std::make_pair(hash, ent.get())); // cache cleaned from Field::~Field } }; diff --git a/src/pv/pvIntrospect.h b/src/pv/pvIntrospect.h index 9ebed70..9458571 100644 --- a/src/pv/pvIntrospect.h +++ b/src/pv/pvIntrospect.h @@ -351,6 +351,7 @@ private: const Type m_fieldType; unsigned int m_hash; struct Helper; + friend struct Helper; friend class StructureArray; friend class Structure;