Index: ext/libicpf/src/cfg.cpp =================================================================== diff -u -r0e69c2afbbe421971214a48e18c00f24a051518f -r8d691767fb8f0643d990f2613daffd4ec18422fa --- ext/libicpf/src/cfg.cpp (.../cfg.cpp) (revision 0e69c2afbbe421971214a48e18c00f24a051518f) +++ ext/libicpf/src/cfg.cpp (.../cfg.cpp) (revision 8d691767fb8f0643d990f2613daffd4ec18422fa) @@ -31,6 +31,8 @@ #ifdef USE_ENCRYPTION #include "crypt.h" #endif +#include + /// Specifies maximum line length of the .conf file #define MAX_LINE 1024 @@ -44,23 +46,41 @@ /// A global instance of a config class config *__g_cfg=NULL; +// to make access faster +#define m_pvProperties ((std::vector*)m_pProperties) + ////////////////////////////////////////////////////////////////////////////////// // prop_group class +/** Standard constructor + */ +prop_group::prop_group(ulong_t ulID) +{ + m_ulGroupID=ulID; + m_pProperties=(void*)new std::vector; +} + +/** Standard destructor + */ +prop_group::~prop_group() +{ + delete m_pvProperties; +} + /** Function adds a new property id to the group. * \param[in] iProp - id of a property to add */ void prop_group::add(int_t iProp) { - m_vProperties.push_back(iProp); + m_pvProperties->push_back(iProp); } /** Function searches for a specific property id inside the list. * \return True if the property has been found, false if not. */ bool prop_group::is_set(int_t iProp) { - for (std::vector::iterator it=m_vProperties.begin();it != m_vProperties.end();it++) + for (std::vector::iterator it=m_pvProperties->begin();it != m_pvProperties->end();it++) { if ((*it) == iProp) return true; @@ -74,7 +94,7 @@ */ ulong_t prop_group::count() { - return (ulong_t)m_vProperties.size(); + return (ulong_t)m_pvProperties->size(); } /** Function returns a property ID at a specified index. @@ -83,7 +103,7 @@ */ int_t prop_group::get_at(int_t iIndex) { - return m_vProperties.at(iIndex); + return m_pvProperties->at(iIndex); } /** Function returns the group id. @@ -97,6 +117,9 @@ ///////////////////////////////////////////////////////////////////////////////////// // config class +#define m_pvProps ((std::vector<_PROP>*)m_pProps) +#define m_pvUnreg ((std::vector<_PROP>*)m_pUnreg) + /** Retrieves a pointer to a global instance of a config class * \return Pointer to the config class */ @@ -112,6 +135,9 @@ config::config(bool bGlobal) :m_bModified(false) { + m_pProps=(void*)new std::vector<_PROP>; + m_pUnreg=(void*)new std::vector<_PROP>; + if (bGlobal) __g_cfg=this; } @@ -120,6 +146,8 @@ */ config::~config() { + delete m_pvProps; + delete m_pvUnreg; } /** Function opens the specified file, reads all the lines sequentially @@ -213,7 +241,7 @@ // encrypt everything if needed try { - for (std::vector<_PROP>::iterator it = m_vProps.begin();it != m_vProps.end();it++) + for (std::vector<_PROP>::iterator it = m_pvProps->begin();it != m_pvProps->end();it++) { encrypt_property(&(*it)); } @@ -227,7 +255,7 @@ bool bFnd=false; string str; - for (std::vector<_PROP>::iterator it=m_vProps.begin();it != m_vProps.end();it++) + for (std::vector<_PROP>::iterator it=m_pvProps->begin();it != m_pvProps->end();it++) { // process only if the property was modified // NOTE: if the file has been modified manually then they won't be overwritten @@ -286,7 +314,7 @@ { m_lock.lock(); - int_t iRet=m_vProps.at(iProp).iType & PTM_TYPE; + int_t iRet=m_pvProps->at(iProp).iType & PTM_TYPE; m_lock.unlock(); return iRet; @@ -328,8 +356,8 @@ else { // get the entry - prop=m_vUnreg.at(iRes); - m_vUnreg.erase(m_vUnreg.begin()+iRes); + prop=m_pvUnreg->at(iRes); + m_pvUnreg->erase(m_pvUnreg->begin()+iRes); // set the value from a string int_t iVal=atol(prop.val.pszVal); @@ -343,9 +371,9 @@ prop.val.i.iHi=iHi; // add to the list - m_vProps.push_back(prop); + m_pvProps->push_back(prop); m_bModified=true; - iRes=(int_t)(m_vProps.size()-1); + iRes=(int_t)(m_pvProps->size()-1); m_lock.unlock(); return iRes; @@ -386,8 +414,8 @@ else { // get the entry - prop=m_vUnreg.at(iRes); - m_vUnreg.erase(m_vUnreg.begin()+iRes); + prop=m_pvUnreg->at(iRes); + m_pvUnreg->erase(m_pvUnreg->begin()+iRes); uint_t uiVal=strtoul(prop.val.pszVal, NULL, 10); delete [] prop.val.pszVal; @@ -400,9 +428,9 @@ prop.val.ui.uiHi=uiHi; // add to the list - m_vProps.push_back(prop); + m_pvProps->push_back(prop); m_bModified=true; - iRes=(int_t)(m_vProps.size()-1); + iRes=(int_t)(m_pvProps->size()-1); m_lock.unlock(); return iRes; @@ -443,8 +471,8 @@ else { // get the entry - prop=m_vUnreg.at(iRes); - m_vUnreg.erase(m_vUnreg.begin()+iRes); + prop=m_pvUnreg->at(iRes); + m_pvUnreg->erase(m_pvUnreg->begin()+iRes); ll_t llVal; #ifdef _WIN32 @@ -462,9 +490,9 @@ prop.val.ll.llHi=llHi; // add to the list - m_vProps.push_back(prop); + m_pvProps->push_back(prop); m_bModified=true; - iRes=(int_t)(m_vProps.size()-1); + iRes=(int_t)(m_pvProps->size()-1); m_lock.unlock(); return iRes; @@ -504,8 +532,8 @@ } else { - prop=m_vUnreg.at(iRes); - m_vUnreg.erase(m_vUnreg.begin()+iRes); + prop=m_pvUnreg->at(iRes); + m_pvUnreg->erase(m_pvUnreg->begin()+iRes); ull_t ullVal; #ifdef _WIN32 @@ -523,9 +551,9 @@ prop.val.ull.ullHi=ullHi; // add to the list - m_vProps.push_back(prop); + m_pvProps->push_back(prop); m_bModified=true; - iRes=(int_t)(m_vProps.size()-1); + iRes=(int_t)(m_pvProps->size()-1); m_lock.unlock(); return iRes; @@ -563,8 +591,8 @@ } else { - prop=m_vUnreg.at(iRes); - m_vUnreg.erase(m_vUnreg.begin()+iRes); + prop=m_pvUnreg->at(iRes); + m_pvUnreg->erase(m_pvUnreg->begin()+iRes); bool bVal; if (strcmp(prop.val.pszVal, "yes") == 0) @@ -582,9 +610,9 @@ prop.iType=PT_BOOL | iFlags; // add to the list - m_vProps.push_back(prop); + m_pvProps->push_back(prop); m_bModified=true; - iRes=(int_t)(m_vProps.size()-1); + iRes=(int_t)(m_pvProps->size()-1); m_lock.unlock(); return iRes; @@ -631,15 +659,15 @@ } else { - prop=m_vUnreg.at(iRes); - m_vUnreg.erase(m_vUnreg.begin()+iRes); + prop=m_pvUnreg->at(iRes); + m_pvUnreg->erase(m_pvUnreg->begin()+iRes); prop.iType = PT_STRING | iFlags; } // add to the list - m_vProps.push_back(prop); + m_pvProps->push_back(prop); m_bModified=true; - iRes=(int_t)(m_vProps.size()-1); + iRes=(int_t)(m_pvProps->size()-1); m_lock.unlock(); return iRes; @@ -655,9 +683,9 @@ { m_lock.lock(); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_INT); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_INT); - int_t iRet=m_vProps.at(iProp).val.i.iVal; + int_t iRet=m_pvProps->at(iProp).val.i.iVal; m_lock.unlock(); return iRet; } @@ -671,9 +699,9 @@ { m_lock.lock(); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_UINT); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_UINT); - int_t ulRet=m_vProps.at(iProp).val.ui.uiVal; + int_t ulRet=m_pvProps->at(iProp).val.ui.uiVal; m_lock.unlock(); return ulRet; } @@ -687,9 +715,9 @@ { m_lock.lock(); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_LONGLONG); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_LONGLONG); - longlong_t llRet=m_vProps.at(iProp).val.ll.llVal; + longlong_t llRet=m_pvProps->at(iProp).val.ll.llVal; m_lock.unlock(); return llRet; } @@ -703,9 +731,9 @@ { m_lock.lock(); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_ULONGLONG); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_ULONGLONG); - ulonglong_t ullRet=m_vProps.at(iProp).val.ull.ullVal; + ulonglong_t ullRet=m_pvProps->at(iProp).val.ull.ullVal; m_lock.unlock(); return ullRet; } @@ -719,9 +747,9 @@ { m_lock.lock(); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_BOOL); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_BOOL); - bool bRet=m_vProps.at(iProp).val.bVal; + bool bRet=m_pvProps->at(iProp).val.bVal; m_lock.unlock(); return bRet; } @@ -737,9 +765,9 @@ { m_lock.lock(); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_STRING); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_STRING); - _PROP& prop=m_vProps.at(iProp); + _PROP& prop=m_pvProps->at(iProp); #ifdef USE_ENCRYPTION // if the property is encrypted and not decoded yet - decode it @@ -771,9 +799,9 @@ { m_lock.lock(); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_STRING); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_STRING); - _PROP& prop=m_vProps.at(iProp); + _PROP& prop=m_pvProps->at(iProp); #ifdef USE_ENCRYPTION // if the property is encrypted and not decoded yet - decode it @@ -807,9 +835,9 @@ m_lock.lock(); // get the data - _PROP& prop=m_vProps.at(iProp); + _PROP& prop=m_pvProps->at(iProp); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_INT); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_INT); int_t iOldVal=prop.val.i.iVal; @@ -852,9 +880,9 @@ m_lock.lock(); // get the data - _PROP& prop=m_vProps.at(iProp); + _PROP& prop=m_pvProps->at(iProp); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_UINT); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_UINT); uint_t uiOldVal=prop.val.ui.uiVal; @@ -898,9 +926,9 @@ m_lock.lock(); // get the data - _PROP& prop=m_vProps.at(iProp); + _PROP& prop=m_pvProps->at(iProp); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_LONGLONG); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_LONGLONG); ll_t llOldVal=prop.val.ll.llVal; @@ -944,9 +972,9 @@ m_lock.lock(); // get the data - _PROP& prop=m_vProps.at(iProp); + _PROP& prop=m_pvProps->at(iProp); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_ULONGLONG); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_ULONGLONG); ull_t ullOldVal=prop.val.ull.ullVal; @@ -990,8 +1018,8 @@ m_lock.lock(); // get the data - _PROP& prop=m_vProps.at(iProp); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_BOOL); + _PROP& prop=m_pvProps->at(iProp); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_BOOL); bool bMod=(prop.val.bVal != bVal); if (bMod) @@ -1025,9 +1053,9 @@ { m_lock.lock(); - _PROP& prop=m_vProps.at(iProp); + _PROP& prop=m_pvProps->at(iProp); - assert((m_vProps.at(iProp).iType & PTM_TYPE) == PT_STRING); + assert((m_pvProps->at(iProp).iType & PTM_TYPE) == PT_STRING); delete [] prop.val.pszVal; prop.val.pszVal=new char_t[strlen(pszVal)+1]; @@ -1093,7 +1121,7 @@ // decrypt everything (if not already) using old password (if exists) try { - for (std::vector<_PROP>::iterator it=m_vProps.begin();it != m_vProps.end();it++) + for (std::vector<_PROP>::iterator it=m_pvProps->begin();it != m_pvProps->end();it++) { decrypt_property(&(*it)); } @@ -1209,7 +1237,7 @@ void config::process_line(const char_t* pszName, const char_t* pszValue) { // check if the property name is registered - for (std::vector<_PROP>::iterator it=m_vProps.begin();it != m_vProps.end();it++) + for (std::vector<_PROP>::iterator it=m_pvProps->begin();it != m_pvProps->end();it++) { if (strcmp((*it).pszName, pszName) == 0) { @@ -1287,7 +1315,7 @@ prop.val.pszVal=new char_t[strlen(pszValue)+1]; strcpy(prop.val.pszVal, pszValue); - m_vUnreg.push_back(prop); + m_pvUnreg->push_back(prop); } /** Prepares the string with the property value to be written to a file. @@ -1348,10 +1376,10 @@ int_t config::is_registered(const char_t* pszName) { // enum through all of the existing nodes - for (std::vector<_PROP>::iterator it=m_vProps.begin();it != m_vProps.end();it++) + for (std::vector<_PROP>::iterator it=m_pvProps->begin();it != m_pvProps->end();it++) { if (strcmp(pszName, (*it).pszName) == 0) - return (int_t)(it-m_vProps.begin()); + return (int_t)(it-m_pvProps->begin()); } return -1; // no property found @@ -1365,10 +1393,10 @@ int_t config::is_unreg(const char_t* pszName) { // enum through all of the existing nodes - for (std::vector<_PROP>::iterator it=m_vUnreg.begin();it != m_vUnreg.end();it++) + for (std::vector<_PROP>::iterator it=m_pvUnreg->begin();it != m_pvUnreg->end();it++) { if (strcmp(pszName, (*it).pszName) == 0) - return (int_t)(it-m_vUnreg.begin()); + return (int_t)(it-m_pvUnreg->begin()); } return -1; // no property found Index: ext/libicpf/src/cfg.h =================================================================== diff -u -r8e565f9442ee4105af5eb0b2bfbc9cec8d3584e4 -r8d691767fb8f0643d990f2613daffd4ec18422fa --- ext/libicpf/src/cfg.h (.../cfg.h) (revision 8e565f9442ee4105af5eb0b2bfbc9cec8d3584e4) +++ ext/libicpf/src/cfg.h (.../cfg.h) (revision 8d691767fb8f0643d990f2613daffd4ec18422fa) @@ -23,7 +23,6 @@ /** \file cfg.h * \brief A placeholder for config class. */ -#include #include "mutex.h" #include "libicpf.h" #include "gen_types.h" @@ -123,8 +122,8 @@ class LIBICPF_API prop_group { public: - prop_group(ulong_t ulID) { m_ulGroupID=ulID; }; ///< Standard constructor - ~prop_group() { }; ///< Standard destructor + prop_group(ulong_t ulID); ///< Standard constructor + ~prop_group(); ///< Standard destructor void add(int_t iProp); ///< Adds a new property id to the list bool is_set(int_t iProp); ///< Checks if a property id is set inside this list @@ -133,8 +132,9 @@ ulong_t get_groupid(); ///< Retrieves the group id protected: - std::vector m_vProperties; ///< List of properties in a group - ulong_t m_ulGroupID; ///< The group ID + void* m_pProperties; ///< Internal member. Pointer to a storage structure with an int_t. +// std::vector m_vProperties; ///< List of properties in a group + ulong_t m_ulGroupID; ///< The group ID }; /** \brief Configuration management class. @@ -241,8 +241,9 @@ public: mutex m_lock; ///< Lock for the multi-threaded access to the properties - std::vector<_PROP> m_vProps; ///< Vector with properties - std::vector<_PROP> m_vUnreg; ///< Properties read from file, but not registered. + void* m_pProps; ///< Properties' storage + void* m_pUnreg; ///< Properties read from file, but not registered. + bool m_bModified; ///< Global modification flag - states if any property is in modified state #ifdef USE_ENCRYPTION Index: ext/libicpf/src/module.cpp =================================================================== diff -u -re17c80d36eaa0430313e7d1058aa7a301d1510af -r8d691767fb8f0643d990f2613daffd4ec18422fa --- ext/libicpf/src/module.cpp (.../module.cpp) (revision e17c80d36eaa0430313e7d1058aa7a301d1510af) +++ ext/libicpf/src/module.cpp (.../module.cpp) (revision 8d691767fb8f0643d990f2613daffd4ec18422fa) @@ -31,6 +31,8 @@ BEGIN_ICPF_NAMESPACE +#define m_pmMods ((std::map*)m_pMods) + /** Constructs a module_param class and initializes all the internal members * to their initial values. */ @@ -44,7 +46,6 @@ */ module_param::~module_param() { - } /** Locks the class (multi-threaded access). @@ -136,7 +137,7 @@ */ modparam_list::modparam_list() { - + m_pMods=new std::map; } /** Standard destructor - clears the internal list of module_params. Also, each entry @@ -146,6 +147,7 @@ modparam_list::~modparam_list() { clear(true); + delete m_pmMods; } /** Inserts a module_param to this list. @@ -157,7 +159,7 @@ { assert(pEntry); m_lock.lock(); - m_mMods.insert(std::pair(pEntry->get_moduleid(), pEntry)); + m_pmMods->insert(std::pair(pEntry->get_moduleid(), pEntry)); m_lock.unlock(); } @@ -170,13 +172,13 @@ bool modparam_list::remove(moduleid_t tEntry, bool bDelete) { m_lock.lock(); - std::map::iterator it = m_mMods.find(tEntry); - if (it != m_mMods.end()) + std::map::iterator it = m_pmMods->find(tEntry); + if (it != m_pmMods->end()) { // delete if needed if (bDelete) delete it->second; - m_mMods.erase(it); + m_pmMods->erase(it); m_lock.unlock(); return true; } @@ -195,13 +197,13 @@ m_lock.lock(); if (bDelete) { - for (std::map::iterator it=m_mMods.begin();it != m_mMods.end();it++) + for (std::map::iterator it=m_pmMods->begin();it != m_pmMods->end();it++) { delete it->second; } } - m_mMods.clear(); + m_pmMods->clear(); m_lock.unlock(); } @@ -212,8 +214,8 @@ module_param* modparam_list::find(moduleid_t mid) { m_lock.lock(); - std::map::iterator it = m_mMods.find(mid); - if (it != m_mMods.end()) + std::map::iterator it = m_pmMods->find(mid); + if (it != m_pmMods->end()) { m_lock.unlock(); return it->second; @@ -234,7 +236,7 @@ m_lock.lock(); try { - for (std::map::iterator it=m_mMods.begin();it != m_mMods.end();it++) + for (std::map::iterator it=m_pmMods->begin();it != m_pmMods->end();it++) { it->second->read_config(pcfg); } @@ -255,7 +257,7 @@ m_lock.lock(); try { - for (std::map::iterator it=m_mMods.begin();it != m_mMods.end();it++) + for (std::map::iterator it=m_pmMods->begin();it != m_pmMods->end();it++) { it->second->write_config(pcfg); } @@ -276,7 +278,7 @@ m_lock.lock(); try { - for (std::map::iterator it=m_mMods.begin();it != m_mMods.end();it++) + for (std::map::iterator it=m_pmMods->begin();it != m_pmMods->end();it++) { it->second->register_properties(pcfg); } @@ -297,7 +299,7 @@ m_lock.lock(); try { - for (std::map::iterator it=m_mMods.begin();it != m_mMods.end();it++) + for (std::map::iterator it=m_pmMods->begin();it != m_pmMods->end();it++) { it->second->store(ser); } @@ -318,7 +320,7 @@ m_lock.lock(); try { - for (std::map::iterator it=m_mMods.begin();it != m_mMods.end();it++) + for (std::map::iterator it=m_pmMods->begin();it != m_pmMods->end();it++) { it->second->load(ser); } @@ -617,12 +619,17 @@ } ///////////////////////////////////////////////////////////////// +#define m_pvModules ((std::vector*)m_vModules) +#define m_pmModules ((std::map*)m_mModules) + /** Constructor - makes a copy of the MODULE_INITDATA structure and * stores it in the internal member. */ module_list::module_list(const MODULE_INITDATA* pData) { m_pmid=pData; + m_vModules=(void*)new std::vector; + m_mModules=(void*)new std::map; } /** Destructor - calls the remove_all(true) to get rid of all modules before @@ -640,6 +647,9 @@ LOG_EXCEPTION(e, m_pmid->plog); e->del(); } + + delete m_pvModules; + delete m_pmModules; } #ifndef _WIN32 @@ -746,8 +756,8 @@ module* mod; m_lock.lock(); - std::map::iterator it=m_mModules.find(mid); - if (it != m_mModules.end()) + std::map::iterator it=m_pmModules->find(mid); + if (it != m_pmModules->end()) mod=(*it).second; else mod=NULL; @@ -765,10 +775,10 @@ */ module* module_list::at(size_t tPos) { - assert(tPos < m_vModules.size()); + assert(tPos < m_pvModules->size()); m_lock.lock(); - module* mod=m_vModules.at(tPos); + module* mod=m_pvModules->at(tPos); m_lock.unlock(); return mod; @@ -792,8 +802,8 @@ try { - std::map::iterator it=m_mModules.find(tModule->get_id()); - if (it != m_mModules.end()) + std::map::iterator it=m_pmModules->find(tModule->get_id()); + if (it != m_pmModules->end()) { THROW(exception::format("Module with a specified id=" MODIDXFMT " (name: " STRFMT ", version: " STRFMT ", author: " STRFMT ") already exists (name: " STRFMT ", version: " STRFMT ", author: " STRFMT ")", tModule->get_id(), tModule->get_name(), tModule->get_version(), tModule->get_author(), @@ -804,13 +814,13 @@ { if (tPos != (size_t)-1) { - assert(tPos <= m_vModules.size()); - m_vModules.insert(m_vModules.begin()+tPos, tModule); + assert(tPos <= m_pvModules->size()); + m_pvModules->insert(m_pvModules->begin()+tPos, tModule); } else - m_vModules.push_back(tModule); + m_pvModules->push_back(tModule); - m_mModules.insert(std::pair(tModule->get_id(), tModule)); + m_pmModules->insert(std::pair(tModule->get_id(), tModule)); } m_lock.unlock(); @@ -862,10 +872,10 @@ */ void module_list::swap(size_t tPos1, size_t tPos2) { - assert(tPos1 <= m_vModules.size() && tPos2 <= m_vModules.size()); + assert(tPos1 <= m_pvModules->size() && tPos2 <= m_pvModules->size()); m_lock.lock(); - swap(m_vModules.begin()+tPos1, m_vModules.begin()+tPos2); + swap(m_pvModules->begin()+tPos1, m_pvModules->begin()+tPos2); m_lock.unlock(); } @@ -875,16 +885,16 @@ */ void module_list::move(moduleid_t tID, size_t tNewPos) { - assert(tNewPos < m_vModules.size()); + assert(tNewPos < m_pvModules->size()); m_lock.lock(); std::vector::iterator it; if (find_module(tID, &it)) { module* mod=(*it); - m_vModules.erase(it); - m_vModules.insert(m_vModules.begin()+tNewPos, mod); + m_pvModules->erase(it); + m_pvModules->insert(m_pvModules->begin()+tNewPos, mod); } m_lock.unlock(); @@ -899,14 +909,14 @@ m_lock.lock(); // clear the vector - m_vModules.clear(); + m_pvModules->clear(); // and now process the data from map module* mod; for (std::vector::iterator it=vIDs->begin();it != vIDs->end();it++) { if ( (mod=find(*it)) != NULL_MODULE ) - m_vModules.push_back(mod); + m_pvModules->push_back(mod); } m_lock.unlock(); @@ -920,7 +930,7 @@ { m_lock.lock(); - for (std::vector::iterator it=m_vModules.begin();it != m_vModules.end();it++) + for (std::vector::iterator it=m_pvModules->begin();it != m_pvModules->end();it++) { vIDs->push_back((*it)->get_id()); } @@ -934,7 +944,7 @@ size_t module_list::size() { m_lock.lock(); - size_t tLen=m_vModules.size(); + size_t tLen=m_pvModules->size(); m_lock.unlock(); return tLen; @@ -988,14 +998,14 @@ */ bool module_list::remove(size_t tPos, bool bForce) { - assert(tPos <= m_vModules.size()); + assert(tPos <= m_pvModules->size()); m_lock.lock(); bool bRes; try { - bRes=remove(m_vModules.begin()+tPos, bForce); + bRes=remove(m_pvModules->begin()+tPos, bForce); m_lock.unlock(); } catch(...) @@ -1016,8 +1026,8 @@ void module_list::remove_all(bool bForce) { m_lock.lock(); - std::vector::iterator it=m_vModules.end(); - while (it != m_vModules.begin()) + std::vector::iterator it=m_pvModules->end(); + while (it != m_pvModules->begin()) { try { @@ -1105,10 +1115,10 @@ } // remove the module from the list - m_vModules.erase(it); - std::map::iterator mit=m_mModules.find(tid); - if (mit != m_mModules.end()) - m_mModules.erase(mit); + m_pvModules->erase(it); + std::map::iterator mit=m_pmModules->find(tid); + if (mit != m_pmModules->end()) + m_pmModules->erase(mit); m_pmid->plog->logi("[module_list] Module (id=" MODIDXFMT ") removed successfully", tid); return true; @@ -1134,9 +1144,9 @@ { // find the requested module std::vector::iterator it; - (*pit)=m_vModules.end(); + (*pit)=m_pvModules->end(); - for (it=m_vModules.begin();it != m_vModules.end();it++) + for (it=m_pvModules->begin();it != m_pvModules->end();it++) { // check if this is one of the requested modules if ((*it)->get_id() == tID) @@ -1146,7 +1156,7 @@ } } - return ((*pit) != m_vModules.end()); + return ((*pit) != m_pvModules->end()); } /** Searches for a specified modules (by their ID's) and stores the iterators in the iterators @@ -1159,9 +1169,9 @@ { // find the requested module std::vector::iterator it; - (*pit1)=(*pit2)=m_vModules.end(); + (*pit1)=(*pit2)=m_pvModules->end(); - for (it=m_vModules.begin();it != m_vModules.end();it++) + for (it=m_pvModules->begin();it != m_pvModules->end();it++) { // check if this is one of the requested modules if ((*it)->get_id() == tID1) @@ -1170,7 +1180,7 @@ (*pit2)=it; } - return ((*pit1) != m_vModules.end() && (*pit2) != m_vModules.end()); + return ((*pit1) != m_pvModules->end() && (*pit2) != m_pvModules->end()); } END_ICPF_NAMESPACE Index: ext/libicpf/src/module.h =================================================================== diff -u -re17c80d36eaa0430313e7d1058aa7a301d1510af -r8d691767fb8f0643d990f2613daffd4ec18422fa --- ext/libicpf/src/module.h (.../module.h) (revision e17c80d36eaa0430313e7d1058aa7a301d1510af) +++ ext/libicpf/src/module.h (.../module.h) (revision 8d691767fb8f0643d990f2613daffd4ec18422fa) @@ -178,7 +178,8 @@ /**@}*/ protected: - std::map m_mMods; ///< Internal map of module parameters + void* m_pMods; ///< Internal map of module parameters +// std::map m_mMods; mutex m_lock; ///< A locking mutex }; @@ -404,8 +405,10 @@ #endif protected: - std::vector m_vModules; ///< Vector with the loaded modules (used to make this class preserve the module positions) - std::map m_mModules; ///< Mapping module id->module pointer +// std::vector m_vModules; +// std::map m_mModules; + void* m_vModules; ///< Array of modules (used to make this class preserve the module positions) - internal. + void* m_mModules; ///< Mapping module id->module pointer (internal) const MODULE_INITDATA* m_pmid; ///< Module initialization data (used for module::init() functions and/or constructors) mutex m_lock; ///< Thread-safe access guarantee