diff --git a/src/common/classes/Hash.h b/src/common/classes/Hash.h index 0dae710d66..c0ec14bc35 100644 --- a/src/common/classes/Hash.h +++ b/src/common/classes/Hash.h @@ -201,7 +201,7 @@ namespace Firebird public: bool add(C* value) { - Entry** e = locate(KeyOfValue::generate(this, *value)); + Entry** e = locate(KeyOfValue::generate(*value)); if (*e) { return false; // sorry, duplicate diff --git a/src/common/classes/array.h b/src/common/classes/array.h index c1efb72d60..fa8c173986 100644 --- a/src/common/classes/array.h +++ b/src/common/classes/array.h @@ -498,14 +498,14 @@ public: while (highBound > lowBound) { const size_t temp = (highBound + lowBound) >> 1; - if (Cmp::greaterThan(item, KeyOfValue::generate(this, this->data[temp]))) + if (Cmp::greaterThan(item, KeyOfValue::generate(this->data[temp]))) lowBound = temp + 1; else highBound = temp; } pos = lowBound; return highBound != this->count && - !Cmp::greaterThan(KeyOfValue::generate(this, this->data[lowBound]), item); + !Cmp::greaterThan(KeyOfValue::generate(this->data[lowBound]), item); } bool exist(const Key& item) const @@ -518,7 +518,7 @@ public: { size_t pos; if (sortMode == FB_ARRAY_SORT_WHEN_ADD) - find(KeyOfValue::generate(this, item), pos); + find(KeyOfValue::generate(item), pos); else { sorted = false; @@ -542,7 +542,7 @@ public: if (sorted) return; - qsort(this->begin(), this->getCount(), sizeof(Value), compar); + qsort(this->begin(), this->getCount(), sizeof(Value), compare); sorted = true; } @@ -550,17 +550,10 @@ private: int sortMode; bool sorted; - static int compar(const void* a, const void* b) + static int compare(const void* a, const void* b) { - // Calling generate() with NULL argument looks dangerous and wrong. - // Correct solution is to use qsort_s/qsort_r functions instead qsort. - // But in our sources the only place using 'sender' in generate() is BPlusTree - // and not with SortedArray but with SortedVector. Using qsort_r/s is overhead for us. - // As an additional disaster there are 2 incompatible (BSD/glibc) clones of qsort_r. - // It's also possible to change SortedArray API without loosing functionality. - // I suppose we can do a choice a bit later. AP-2013. - const Key& first(KeyOfValue::generate(NULL, *reinterpret_cast(a))); - const Key& second(KeyOfValue::generate(NULL, *reinterpret_cast(b))); + const Key& first(KeyOfValue::generate(*reinterpret_cast(a))); + const Key& second(KeyOfValue::generate(*reinterpret_cast(b))); if (Cmp::greaterThan(first, second)) return 1; diff --git a/src/common/classes/fb_pair.h b/src/common/classes/fb_pair.h index 9232e4588d..0396624327 100644 --- a/src/common/classes/fb_pair.h +++ b/src/common/classes/fb_pair.h @@ -149,6 +149,10 @@ template { public: typedef typename P::first_type Pair_first_type; + static const Pair_first_type& generate(const P& item) + { + return item.first; + } static const Pair_first_type& generate(const void* /*sender*/, const P& item) { return item.first; @@ -160,6 +164,10 @@ template { public: typedef typename P::first_type Pair_first_type; + static const Pair_first_type* generate(const P* item) + { + return &item->first; + } static const Pair_first_type* generate(const void* /*sender*/, const P* item) { return &item->first; @@ -171,6 +179,10 @@ template { public: typedef typename P::first_type Pair_first_type; + static const Pair_first_type& generate(const P* item) + { + return item->first; + } static const Pair_first_type& generate(const void* /*sender*/, const P* item) { return item->first; diff --git a/src/common/classes/objects_array.h b/src/common/classes/objects_array.h index 27b610379d..190796629b 100644 --- a/src/common/classes/objects_array.h +++ b/src/common/classes/objects_array.h @@ -360,7 +360,7 @@ namespace Firebird class ObjectKeyValue { public: - static const T& generate(const void* /*sender*/, const T* item) { return item; } + static const T& generate(const T* item) { return item; } }; // Template for default value comparator diff --git a/src/common/classes/vector.h b/src/common/classes/vector.h index 2232fd5fb1..f4a92fc5bc 100644 --- a/src/common/classes/vector.h +++ b/src/common/classes/vector.h @@ -140,6 +140,7 @@ class DefaultKeyValue { public: static const T& generate(const void* /*sender*/, const T& item) { return item; } + static const T& generate(const T& item) { return item; } }; // Fast sorted array of simple objects diff --git a/src/common/config/config_file.h b/src/common/config/config_file.h index f50c14ac8f..50ca3910bf 100644 --- a/src/common/config/config_file.h +++ b/src/common/config/config_file.h @@ -90,7 +90,7 @@ public: Firebird::RefPtr sub; unsigned int line; - static const KeyType* generate(const void* /*sender*/, const Parameter* item) + static const KeyType* generate(const Parameter* item) { return &item->name; } diff --git a/src/common/db_alias.cpp b/src/common/db_alias.cpp index a7f806e577..3f44dea0b7 100644 --- a/src/common/db_alias.cpp +++ b/src/common/db_alias.cpp @@ -72,7 +72,7 @@ namespace template struct PathHash { - static const PathName& generate(const void* /*sender*/, const T& item) + static const PathName& generate(const T& item) { return item.name; } diff --git a/src/jrd/DebugInterface.h b/src/jrd/DebugInterface.h index e22106c144..5560f53b3e 100644 --- a/src/jrd/DebugInterface.h +++ b/src/jrd/DebugInterface.h @@ -44,7 +44,7 @@ public: ULONG mbs_src_line; ULONG mbs_src_col; - static ULONG generate(const void*, const MapBlrToSrcItem& Item) + static ULONG generate(const MapBlrToSrcItem& Item) { return Item.mbs_offset; } }; diff --git a/src/jrd/GarbageCollector.h b/src/jrd/GarbageCollector.h index 61eb4ecf22..75469424b3 100644 --- a/src/jrd/GarbageCollector.h +++ b/src/jrd/GarbageCollector.h @@ -77,7 +77,7 @@ private: return m_relID; } - static inline const USHORT generate(void const*, const RelationData* item) + static inline const USHORT generate(const RelationData* item) { return item->m_relID; } diff --git a/src/jrd/Relation.h b/src/jrd/Relation.h index 2aa0a286e3..bfeed5093e 100644 --- a/src/jrd/Relation.h +++ b/src/jrd/Relation.h @@ -49,7 +49,7 @@ public: { } - static USHORT generate(const void*, const ViewContext* vc) + static USHORT generate(const ViewContext* vc) { return vc->vcx_context; } @@ -97,7 +97,7 @@ public: void free(RelationPages*& nextFree); - static inline ULONG generate(const void*, const RelationPages* item) + static inline ULONG generate(const RelationPages* item) { return item->rel_instance_id; } diff --git a/src/jrd/RuntimeStatistics.h b/src/jrd/RuntimeStatistics.h index 1df7c98298..1e0f06c192 100644 --- a/src/jrd/RuntimeStatistics.h +++ b/src/jrd/RuntimeStatistics.h @@ -64,12 +64,12 @@ struct RelationCounts SINT64 rlc_counter[DBB_max_count]; #ifdef REL_COUNTS_PTR - inline static const SLONG* generate(const void* /*sender*/, const RelationCounts* item) + inline static const SLONG* generate(const RelationCounts* item) { return &item->rlc_relation_id; } #else - inline static const SLONG& generate(const void* /*sender*/, const RelationCounts& item) + inline static const SLONG& generate(const RelationCounts& item) { return item.rlc_relation_id; } diff --git a/src/jrd/dfw.epp b/src/jrd/dfw.epp index 18e09ca631..7cd6d0a7af 100644 --- a/src/jrd/dfw.epp +++ b/src/jrd/dfw.epp @@ -333,7 +333,7 @@ public: DfwSavePoint* get() { return this; } - static SLONG generate(const void* /*sender*/, const DfwSavePoint& item) + static SLONG generate(const DfwSavePoint& item) { return item.dfw_sav_number; } diff --git a/src/jrd/extds/ExtDS.h b/src/jrd/extds/ExtDS.h index 1b34a43381..f24e662359 100644 --- a/src/jrd/extds/ExtDS.h +++ b/src/jrd/extds/ExtDS.h @@ -114,7 +114,7 @@ public: // Interprete status and put error description into passed string virtual void getRemoteError(const ISC_STATUS* status, Firebird::string& err) const = 0; - static const Firebird::string* generate(const void*, const Provider* item) + static const Firebird::string* generate(const Provider* item) { return &item->m_name; } diff --git a/src/jrd/os/win32/win9x_nt.h b/src/jrd/os/win32/win9x_nt.h index f3c1dd3748..835949d785 100644 --- a/src/jrd/os/win32/win9x_nt.h +++ b/src/jrd/os/win32/win9x_nt.h @@ -44,7 +44,7 @@ struct LocksArrayItem { LocksArrayItem() {} LocksArrayItem(HANDLE handle, Firebird::Mutex* mutex) : first(handle), second(mutex) { } - static HANDLE generate(const void*, LocksArrayItem value) { + static HANDLE generate(LocksArrayItem value) { return value.first; } }; diff --git a/src/jrd/pag.h b/src/jrd/pag.h index 806e71e888..f73ea65f9c 100644 --- a/src/jrd/pag.h +++ b/src/jrd/pag.h @@ -97,7 +97,7 @@ public: return (pageSpaceID >= TEMP_PAGE_SPACE); } - static inline SLONG generate(const void* , const PageSpace* Item) + static inline SLONG generate(const PageSpace* Item) { return Item->pageSpaceID; } diff --git a/src/jrd/rpb_chain.h b/src/jrd/rpb_chain.h index cd02b15bb7..6a53af7c77 100644 --- a/src/jrd/rpb_chain.h +++ b/src/jrd/rpb_chain.h @@ -53,7 +53,7 @@ public: i1.level > i2.level; } - static inline const traRpbListElement& generate(const void* /*sender*/, const traRpbListElement& item) + static inline const traRpbListElement& generate(const traRpbListElement& item) { return item; } diff --git a/src/jrd/sort.cpp b/src/jrd/sort.cpp index a203e85d91..b3a5ce5004 100644 --- a/src/jrd/sort.cpp +++ b/src/jrd/sort.cpp @@ -138,7 +138,7 @@ namespace explicit RunSort(run_control* irun) : run(irun) {} RunSort() : run(NULL) {} - static FB_UINT64 generate(const void*, const RunSort& item) + static FB_UINT64 generate(const RunSort& item) { return item.run->run_seek; } diff --git a/src/jrd/tpc_proto.h b/src/jrd/tpc_proto.h index 562c73f2bd..8d5309f685 100644 --- a/src/jrd/tpc_proto.h +++ b/src/jrd/tpc_proto.h @@ -56,7 +56,7 @@ private: TraNumber tpc_base; // id of first transaction in this block UCHAR tpc_transactions[1]; // two bits per transaction - static const TraNumber generate(const void*, const TxPage* item) + static const TraNumber generate(const TxPage* item) { return item->tpc_base; } diff --git a/src/jrd/trace/TraceManager.h b/src/jrd/trace/TraceManager.h index 4c0fe873aa..b318e427c5 100644 --- a/src/jrd/trace/TraceManager.h +++ b/src/jrd/trace/TraceManager.h @@ -184,7 +184,7 @@ private: TracePlugin* plugin; ULONG ses_id; - static ULONG generate(const void*, const SessionInfo& item) + static ULONG generate(const SessionInfo& item) { return item.ses_id; } }; class Sessions : public Firebird::SortedArray, ULONG, SessionInfo> diff --git a/src/remote/server/server.cpp b/src/remote/server/server.cpp index 307e54896b..803a0abd73 100644 --- a/src/remote/server/server.cpp +++ b/src/remote/server/server.cpp @@ -124,7 +124,7 @@ public: : login(p, fl.login), failCount(fl.failCount), lastAttempt(fl.lastAttempt) {} - static const string* generate(const void*, const FailedLogin* f) + static const string* generate(const FailedLogin* f) { return &f->login; } diff --git a/src/yvalve/MasterImplementation.cpp b/src/yvalve/MasterImplementation.cpp index 93fccc889a..0c48208ec6 100644 --- a/src/yvalve/MasterImplementation.cpp +++ b/src/yvalve/MasterImplementation.cpp @@ -479,7 +479,7 @@ struct TimerEntry TimerDelay fireTime; ITimer* timer; - static const TimerDelay generate(const void* /*sender*/, const TimerEntry& item) { return item.fireTime; } + static const TimerDelay generate(const TimerEntry& item) { return item.fireTime; } static THREAD_ENTRY_DECLARE timeThread(THREAD_ENTRY_PARAM); static void init()