Commit 73b724ef authored by Pavel Vainerman's avatar Pavel Vainerman

Исправления по результатам проверки утилитой cppcheck

parent 74c567df
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
Name: libuniset Name: libuniset
Version: 1.6 Version: 1.6
Release: alt10 Release: alt11
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
...@@ -319,6 +319,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -319,6 +319,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet.pc %exclude %_pkgconfigdir/libUniSet.pc
%changelog %changelog
* Thu Jun 13 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt11
- fixed after cppcheck checking
* Wed Jun 05 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt10 * Wed Jun 05 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt10
- add for ModbusMaster (RTU|TCP) --xxx--aftersend-pause - add for ModbusMaster (RTU|TCP) --xxx--aftersend-pause
......
...@@ -351,7 +351,7 @@ UNetExchange::~UNetExchange() ...@@ -351,7 +351,7 @@ UNetExchange::~UNetExchange()
delete shm; delete shm;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UNetExchange::checkExistUNetHost( const std::string addr, ost::tpport_t port ) bool UNetExchange::checkExistUNetHost( const std::string& addr, ost::tpport_t port )
{ {
ost::IPV4Address a1(addr.c_str()); ost::IPV4Address a1(addr.c_str());
for( ReceiverList::iterator it=recvlist.begin(); it!=recvlist.end(); ++it ) for( ReceiverList::iterator it=recvlist.begin(); it!=recvlist.end(); ++it )
...@@ -424,7 +424,7 @@ void UNetExchange::step() ...@@ -424,7 +424,7 @@ void UNetExchange::step()
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetExchange::ReceiverInfo::step( SMInterface* shm, const std::string myname ) void UNetExchange::ReceiverInfo::step( SMInterface* shm, const std::string& myname )
{ {
try try
{ {
......
...@@ -89,7 +89,7 @@ class UNetExchange: ...@@ -89,7 +89,7 @@ class UNetExchange:
/*! глобальная функция для вывода help-а */ /*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* argv[] ); static void help_print( int argc, const char* argv[] );
bool checkExistUNetHost( const std::string host, ost::tpport_t port ); bool checkExistUNetHost( const std::string& host, ost::tpport_t port );
protected: protected:
...@@ -142,6 +142,7 @@ class UNetExchange: ...@@ -142,6 +142,7 @@ class UNetExchange:
{ {
ReceiverInfo():r1(0),r2(0), ReceiverInfo():r1(0),r2(0),
sidRespond(UniSetTypes::DefaultObjectId), sidRespond(UniSetTypes::DefaultObjectId),
respondInvert(false),
sidLostPackets(UniSetTypes::DefaultObjectId) sidLostPackets(UniSetTypes::DefaultObjectId)
{} {}
...@@ -155,7 +156,7 @@ class UNetExchange: ...@@ -155,7 +156,7 @@ class UNetExchange:
UNetReceiver* r1; /*!< приём по первому каналу */ UNetReceiver* r1; /*!< приём по первому каналу */
UNetReceiver* r2; /*!< приём по второму каналу */ UNetReceiver* r2; /*!< приём по второму каналу */
void step( SMInterface* shm, const std::string myname ); void step( SMInterface* shm, const std::string& myname );
inline void setRespondID( UniSetTypes::ObjectId id, bool invert=false ) inline void setRespondID( UniSetTypes::ObjectId id, bool invert=false )
{ {
......
...@@ -19,7 +19,7 @@ bool UNetReceiver::PacketCompare::operator()(const UniSetUDP::UDPMessage& lhs, ...@@ -19,7 +19,7 @@ bool UNetReceiver::PacketCompare::operator()(const UniSetUDP::UDPMessage& lhs,
} }
*/ */
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
UNetReceiver::UNetReceiver( const std::string s_host, const ost::tpport_t port, SMInterface* smi ): UNetReceiver::UNetReceiver( const std::string& s_host, const ost::tpport_t port, SMInterface* smi ):
shm(smi), shm(smi),
recvpause(10), recvpause(10),
updatepause(100), updatepause(100),
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
class UNetReceiver class UNetReceiver
{ {
public: public:
UNetReceiver( const std::string host, const ost::tpport_t port, SMInterface* smi ); UNetReceiver( const std::string& host, const ost::tpport_t port, SMInterface* smi );
~UNetReceiver(); ~UNetReceiver();
void start(); void start();
......
...@@ -33,7 +33,7 @@ enum Command ...@@ -33,7 +33,7 @@ enum Command
cmdReceive cmdReceive
}; };
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
static bool split_addr( const string addr, string& host, ost::tpport_t& port ) static bool split_addr( const string& addr, string& host, ost::tpport_t& port )
{ {
string::size_type pos = addr.rfind(':'); string::size_type pos = addr.rfind(':');
if( pos != string::npos ) if( pos != string::npos )
......
...@@ -17,7 +17,7 @@ namespace UniSetExtensions ...@@ -17,7 +17,7 @@ namespace UniSetExtensions
/*! Получение времени для подтверждения "живости" */ /*! Получение времени для подтверждения "живости" */
int getHeartBeatTime(); int getHeartBeatTime();
xmlNode* findNode( xmlNode* node, const std::string snode, const std::string field ); xmlNode* findNode( xmlNode* node, const std::string& snode, const std::string& field );
xmlNode* getCalibrationsSection(); xmlNode* getCalibrationsSection();
...@@ -27,7 +27,7 @@ namespace UniSetExtensions ...@@ -27,7 +27,7 @@ namespace UniSetExtensions
void escape_string( std::string& s ); void escape_string( std::string& s );
/*! Загрузка калибровочной диаграммы */ /*! Загрузка калибровочной диаграммы */
Calibration* buildCalibrationDiagram( const std::string dname ); Calibration* buildCalibrationDiagram( const std::string& dname );
extern DebugStream dlog; extern DebugStream dlog;
} }
......
...@@ -39,7 +39,7 @@ namespace MTR ...@@ -39,7 +39,7 @@ namespace MTR
}; };
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::string type2str( MTRType t ); /*!< преоразование строки в тип */ std::string type2str( MTRType t ); /*!< преоразование строки в тип */
MTRType str2type( const std::string s ); /*!< преобразование названия в строку */ MTRType str2type( const std::string& s ); /*!< преобразование названия в строку */
int wsize( MTRType t ); /*!< длина данных в словах */ int wsize( MTRType t ); /*!< длина данных в словах */
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Информация // Информация
...@@ -100,7 +100,7 @@ namespace MTR ...@@ -100,7 +100,7 @@ namespace MTR
std::ostream& operator<<(std::ostream& os, MTRError& e ); std::ostream& operator<<(std::ostream& os, MTRError& e );
// Настройка из конф. файла // Настройка из конф. файла
MTRError update_configuration( ModbusRTUMaster* mb, ModbusRTU::ModbusAddr addr, MTRError update_configuration( ModbusRTUMaster* mb, ModbusRTU::ModbusAddr addr,
const std::string mtrconfile, int verbose=0 ); const std::string& mtrconfile, int verbose=0 );
// --------------------------- // ---------------------------
// вспомогательные функции и типы данных // вспомогательные функции и типы данных
typedef std::list<ModbusRTU::ModbusData> DataList; typedef std::list<ModbusRTU::ModbusData> DataList;
...@@ -109,8 +109,8 @@ namespace MTR ...@@ -109,8 +109,8 @@ namespace MTR
static const ModbusRTU::ModbusData skip[] = {48, 49, 59}; // registers which should not write static const ModbusRTU::ModbusData skip[] = {48, 49, 59}; // registers which should not write
bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr, int verb ); bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr, int verb );
bool read_param( const std::string str, std::string& str1, std::string& str2 ); bool read_param( const std::string& str, std::string& str1, std::string& str2 );
DataMap read_confile( const std::string f ); DataMap read_confile( const std::string& f );
void update_communication_params( ModbusRTU::ModbusAddr reg, ModbusRTU::ModbusData data, void update_communication_params( ModbusRTU::ModbusAddr reg, ModbusRTU::ModbusData data,
ModbusRTUMaster* mb, ModbusRTU::ModbusAddr& addr, int verb ); ModbusRTUMaster* mb, ModbusRTU::ModbusAddr& addr, int verb );
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
......
...@@ -29,7 +29,7 @@ namespace VTypes ...@@ -29,7 +29,7 @@ namespace VTypes
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::string type2str( VType t ); /*!< преобразование строки в тип */ std::string type2str( VType t ); /*!< преобразование строки в тип */
VType str2type( const std::string s ); /*!< преобразование названия в строку */ VType str2type( const std::string& s ); /*!< преобразование названия в строку */
int wsize( VType t ); /*!< длина данных в словах */ int wsize( VType t ); /*!< длина данных в словах */
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
class F2 class F2
......
...@@ -250,7 +250,7 @@ int DigitalFilter::filterIIR( int newval ) ...@@ -250,7 +250,7 @@ int DigitalFilter::filterIIR( int newval )
} }
else else
{ {
double aver; double aver=0;
add(newval); add(newval);
for( FIFOBuffer::iterator i = buf.begin(); i != buf.end(); ++i ) for( FIFOBuffer::iterator i = buf.begin(); i != buf.end(); ++i )
......
...@@ -89,7 +89,7 @@ namespace UniSetExtensions ...@@ -89,7 +89,7 @@ namespace UniSetExtensions
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
xmlNode* findNode( xmlNode* node, const string snode, const string field ) xmlNode* findNode( xmlNode* node, const string& snode, const string& field )
{ {
if( !node ) if( !node )
return 0; return 0;
...@@ -107,7 +107,7 @@ namespace UniSetExtensions ...@@ -107,7 +107,7 @@ namespace UniSetExtensions
return 0; return 0;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
Calibration* buildCalibrationDiagram( const std::string dname ) Calibration* buildCalibrationDiagram( const std::string& dname )
{ {
xmlNode* root = getCalibrationsSection(); xmlNode* root = getCalibrationsSection();
if( !root ) if( !root )
......
...@@ -503,15 +503,15 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, ...@@ -503,15 +503,15 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
shm->initDIterator(b->d_dit); shm->initDIterator(b->d_dit);
string d_txt(it.getProp("depend")); string d_txt(it.getProp("depend"));
if( !it.getProp("depend").empty() ) if( !d_txt.empty() )
{ {
b->d_id = conf->getSensorID(it.getProp("depend")); b->d_id = conf->getSensorID(d_txt);
if( b->d_id == DefaultObjectId ) if( b->d_id == DefaultObjectId )
{ {
if( dlog ) if( dlog )
dlog[Debug::CRIT] << myname << "(IOBase::readItem): sensor='" dlog[Debug::CRIT] << myname << "(IOBase::readItem): sensor='"
<< it.getProp("name") << "' err: " << it.getProp("name") << "' err: "
<< " Unknown SensorID for depend='" << it.getProp("depend") << " Unknown SensorID for depend='" << d_txt
<< endl; << endl;
return false; return false;
} }
......
...@@ -13,7 +13,7 @@ using namespace std; ...@@ -13,7 +13,7 @@ using namespace std;
namespace MTR namespace MTR
{ {
MTRType str2type( const std::string s ) MTRType str2type( const std::string& s )
{ {
if( s == "T1" ) if( s == "T1" )
return mtT1; return mtT1;
...@@ -227,13 +227,13 @@ std::string getSerialNumber( ModbusRTUMaster* mb, ModbusRTU::ModbusAddr addr ) ...@@ -227,13 +227,13 @@ std::string getSerialNumber( ModbusRTUMaster* mb, ModbusRTU::ModbusAddr addr )
return ""; return "";
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
DataMap read_confile( const std::string f ) DataMap read_confile( const std::string& f )
{ {
bool start = false;
DataMap dmap; DataMap dmap;
std::ifstream ifs(f.c_str(),std::ios::in); std::ifstream ifs(f.c_str(),std::ios::in);
if( ifs ) if( ifs )
{ {
bool start = false;
while( !ifs.eof() ) while( !ifs.eof() )
{ {
std::string str; std::string str;
...@@ -295,7 +295,7 @@ DataMap read_confile( const std::string f ) ...@@ -295,7 +295,7 @@ DataMap read_confile( const std::string f )
return dmap; return dmap;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
bool read_param( const std::string str, std::string& str1, std::string& str2 ) bool read_param( const std::string& str, std::string& str1, std::string& str2 )
{ {
string::size_type pos = str.find('='); string::size_type pos = str.find('=');
if( pos==string::npos ) if( pos==string::npos )
...@@ -385,7 +385,7 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr, ...@@ -385,7 +385,7 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr,
// cout << "send reg=" << ModbusRTU::dat2str(it->first) // cout << "send reg=" << ModbusRTU::dat2str(it->first)
// << "(" << it->first << ")" << endl; // << "(" << it->first << ")" << endl;
int reg = it->first; int reg = it->first;
bool ok = false; // bool ok = false;
for( DataList::iterator it1=it->second.begin(); it1!=it->second.end(); ++it1, reg++ ) for( DataList::iterator it1=it->second.begin(); it1!=it->second.end(); ++it1, reg++ )
{ {
...@@ -406,7 +406,7 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr, ...@@ -406,7 +406,7 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr,
if( verb ) if( verb )
cout << "(mtr-setup): write reply: " << ret << endl; cout << "(mtr-setup): write reply: " << ret << endl;
update_communication_params(reg, *it1, mb, addr, verb); update_communication_params(reg, *it1, mb, addr, verb);
ok = true; // ok = true;
break; break;
} }
catch( ModbusRTU::mbException& ex ) catch( ModbusRTU::mbException& ex )
...@@ -415,7 +415,7 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr, ...@@ -415,7 +415,7 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr,
if( reg == 56 && it->first == ModbusRTU::erTimeOut ) if( reg == 56 && it->first == ModbusRTU::erTimeOut )
{ {
update_communication_params(reg, *it1, mb, addr, verb); update_communication_params(reg, *it1, mb, addr, verb);
ok = true; // ok = true;
break; break;
} }
else else
...@@ -436,7 +436,7 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr, ...@@ -436,7 +436,7 @@ bool send_param( ModbusRTUMaster* mb, DataMap& dmap, ModbusRTU::ModbusAddr addr,
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
MTR::MTRError update_configuration( ModbusRTUMaster* mb, ModbusRTU::ModbusAddr slaveaddr, MTR::MTRError update_configuration( ModbusRTUMaster* mb, ModbusRTU::ModbusAddr slaveaddr,
const std::string mtrconfile, int verb ) const std::string& mtrconfile, int verb )
{ {
std::string m = MTR::getModelNumber(mb, slaveaddr); std::string m = MTR::getModelNumber(mb, slaveaddr);
if( m != "MTR315Transducer" ) if( m != "MTR315Transducer" )
......
...@@ -12,7 +12,7 @@ std::ostream& operator<<( std::ostream& os, const VType& vt ) ...@@ -12,7 +12,7 @@ std::ostream& operator<<( std::ostream& os, const VType& vt )
return os << type2str(vt); return os << type2str(vt);
} }
VType str2type( const std::string s ) VType str2type( const std::string& s )
{ {
if( s == "Byte" || s == "byte" ) if( s == "Byte" || s == "byte" )
return vtByte; return vtByte;
......
...@@ -253,7 +253,7 @@ namespace UniSetTypes ...@@ -253,7 +253,7 @@ namespace UniSetTypes
// Инициализация UniSetTypes::conf. // Инициализация UniSetTypes::conf.
// ( учитываются параметры командной строки --confile и --id-from-config ) // ( учитываются параметры командной строки --confile и --id-from-config )
void uniset_init( int argc, const char* const* argv, const std::string xmlfile="configure.xml" ); void uniset_init( int argc, const char* const* argv, const std::string& xmlfile="configure.xml" );
} // end of UniSetTypes namespace } // end of UniSetTypes namespace
......
...@@ -50,10 +50,10 @@ namespace ORepHelpers ...@@ -50,10 +50,10 @@ namespace ORepHelpers
throw(UniSetTypes::ORepFailed); throw(UniSetTypes::ORepFailed);
//! Функция отделяющая имя секции от полного имени //! Функция отделяющая имя секции от полного имени
const std::string getSectionName(const std::string& fullName, const std::string brk="/"); const std::string getSectionName(const std::string& fullName, const std::string& brk="/");
//! Функция выделения имени из полного имени //! Функция выделения имени из полного имени
const std::string getShortName(const std::string& fullName, const std::string brk="/"); const std::string getShortName(const std::string& fullName, const std::string& brk="/");
//! Проверка на наличие недопустимых символов //! Проверка на наличие недопустимых символов
......
...@@ -92,7 +92,7 @@ long UConnector::getValue( long id, long node )throw(UException) ...@@ -92,7 +92,7 @@ long UConnector::getValue( long id, long node )throw(UException)
} }
catch( UException& ex ) catch( UException& ex )
{ {
throw ex; throw;
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
{ {
...@@ -146,7 +146,7 @@ void UConnector::setValue( long id, long val, long node )throw(UException) ...@@ -146,7 +146,7 @@ void UConnector::setValue( long id, long val, long node )throw(UException)
} }
catch( UException& ex ) catch( UException& ex )
{ {
throw ex; throw;
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
{ {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
struct UException struct UException
{ {
UException(){} UException(){}
UException( const std::string e ):err(e){} UException( const std::string& e ):err(e){}
UException( const char* e ):err( std::string(e)){} UException( const char* e ):err( std::string(e)){}
~UException(){} ~UException(){}
...@@ -17,7 +17,7 @@ struct UTimeOut: ...@@ -17,7 +17,7 @@ struct UTimeOut:
public UException public UException
{ {
UTimeOut():UException("UTimeOut"){} UTimeOut():UException("UTimeOut"){}
UTimeOut( const std::string e ):UException(e){} UTimeOut( const std::string& e ):UException(e){}
~UTimeOut(){} ~UTimeOut(){}
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -25,7 +25,7 @@ struct USysError: ...@@ -25,7 +25,7 @@ struct USysError:
public UException public UException
{ {
USysError():UException("UTimeOut"){} USysError():UException("UTimeOut"){}
USysError( const std::string e ):UException(e){} USysError( const std::string& e ):UException(e){}
~USysError(){} ~USysError(){}
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
......
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org). * This file was automatically generated by SWIG (http://www.swig.org).
* Version 2.0.8 * Version 2.0.9
* *
* This file is not intended to be easily readable and contains a number of * This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make * coding conventions designed to improve portability and efficiency. Do not make
...@@ -927,6 +927,10 @@ static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) ...@@ -927,6 +927,10 @@ static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc))
} }
#endif #endif
#if PY_VERSION_HEX < 0x02050000
#define PyInt_FromSize_t(x) PyInt_FromLong((long)x)
#endif
#if PY_VERSION_HEX < 0x02040000 #if PY_VERSION_HEX < 0x02040000
#define Py_VISIT(op) \ #define Py_VISIT(op) \
do { \ do { \
...@@ -1198,7 +1202,7 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), ...@@ -1198,7 +1202,7 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self),
/* Runtime API */ /* Runtime API */
#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() #define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata)
#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) #define SWIG_NewClientData(obj) SwigPyClientData_New(obj)
...@@ -2637,7 +2641,7 @@ void *SWIG_ReturnGlobalTypeList(void *); ...@@ -2637,7 +2641,7 @@ void *SWIG_ReturnGlobalTypeList(void *);
#endif #endif
SWIGRUNTIME swig_module_info * SWIGRUNTIME swig_module_info *
SWIG_Python_GetModule(void) { SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
static void *type_pointer = (void *)0; static void *type_pointer = (void *)0;
/* first check if module already created */ /* first check if module already created */
if (!type_pointer) { if (!type_pointer) {
...@@ -2763,7 +2767,7 @@ SWIG_Python_TypeQuery(const char *type) ...@@ -2763,7 +2767,7 @@ SWIG_Python_TypeQuery(const char *type)
descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
#endif #endif
} else { } else {
swig_module_info *swig_module = SWIG_Python_GetModule(); swig_module_info *swig_module = SWIG_GetModule(0);
descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
if (descriptor) { if (descriptor) {
#ifdef SWIGPY_USE_CAPSULE #ifdef SWIGPY_USE_CAPSULE
...@@ -2987,7 +2991,7 @@ static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0}; ...@@ -2987,7 +2991,7 @@ static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0};
#endif #endif
#define SWIG_name "_pyUExceptions" #define SWIG_name "_pyUExceptions"
#define SWIGVERSION 0x020008 #define SWIGVERSION 0x020009
#define SWIG_VERSION SWIGVERSION #define SWIG_VERSION SWIGVERSION
...@@ -3200,27 +3204,22 @@ fail: ...@@ -3200,27 +3204,22 @@ fail:
SWIGINTERN PyObject *_wrap_new_UException__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { SWIGINTERN PyObject *_wrap_new_UException__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0; PyObject *resultobj = 0;
std::string arg1 ; std::string *arg1 = 0 ;
void *argp1 ; void *argp1 = 0 ;
int res1 = 0 ; int res1 = 0 ;
PyObject * obj0 = 0 ; PyObject * obj0 = 0 ;
UException *result = 0 ; UException *result = 0 ;
if (!PyArg_ParseTuple(args,(char *)"O:new_UException",&obj0)) SWIG_fail; if (!PyArg_ParseTuple(args,(char *)"O:new_UException",&obj0)) SWIG_fail;
{ res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__string, 0 | 0);
res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__string, 0 | 0); if (!SWIG_IsOK(res1)) {
if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_UException" "', argument " "1"" of type '" "std::string const &""'");
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_UException" "', argument " "1"" of type '" "std::string const""'"); }
} if (!argp1) {
if (!argp1) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_UException" "', argument " "1"" of type '" "std::string const &""'");
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_UException" "', argument " "1"" of type '" "std::string const""'");
} else {
std::string * temp = reinterpret_cast< std::string * >(argp1);
arg1 = *temp;
if (SWIG_IsNewObj(res1)) delete temp;
}
} }
result = (UException *)new UException(arg1); arg1 = reinterpret_cast< std::string * >(argp1);
result = (UException *)new UException((std::string const &)*arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_UException, SWIG_POINTER_NEW | 0 ); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_UException, SWIG_POINTER_NEW | 0 );
return resultobj; return resultobj;
fail: fail:
...@@ -3287,7 +3286,7 @@ fail: ...@@ -3287,7 +3286,7 @@ fail:
SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_UException'.\n" SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_UException'.\n"
" Possible C/C++ prototypes are:\n" " Possible C/C++ prototypes are:\n"
" UException::UException()\n" " UException::UException()\n"
" UException::UException(std::string const)\n" " UException::UException(std::string const &)\n"
" UException::UException(char const *)\n"); " UException::UException(char const *)\n");
return 0; return 0;
} }
...@@ -3418,27 +3417,22 @@ fail: ...@@ -3418,27 +3417,22 @@ fail:
SWIGINTERN PyObject *_wrap_new_UTimeOut__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { SWIGINTERN PyObject *_wrap_new_UTimeOut__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0; PyObject *resultobj = 0;
std::string arg1 ; std::string *arg1 = 0 ;
void *argp1 ; void *argp1 = 0 ;
int res1 = 0 ; int res1 = 0 ;
PyObject * obj0 = 0 ; PyObject * obj0 = 0 ;
UTimeOut *result = 0 ; UTimeOut *result = 0 ;
if (!PyArg_ParseTuple(args,(char *)"O:new_UTimeOut",&obj0)) SWIG_fail; if (!PyArg_ParseTuple(args,(char *)"O:new_UTimeOut",&obj0)) SWIG_fail;
{ res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__string, 0 | 0);
res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__string, 0 | 0); if (!SWIG_IsOK(res1)) {
if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_UTimeOut" "', argument " "1"" of type '" "std::string const &""'");
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_UTimeOut" "', argument " "1"" of type '" "std::string const""'");
}
if (!argp1) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_UTimeOut" "', argument " "1"" of type '" "std::string const""'");
} else {
std::string * temp = reinterpret_cast< std::string * >(argp1);
arg1 = *temp;
if (SWIG_IsNewObj(res1)) delete temp;
}
} }
result = (UTimeOut *)new UTimeOut(arg1); if (!argp1) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_UTimeOut" "', argument " "1"" of type '" "std::string const &""'");
}
arg1 = reinterpret_cast< std::string * >(argp1);
result = (UTimeOut *)new UTimeOut((std::string const &)*arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_UTimeOut, SWIG_POINTER_NEW | 0 ); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_UTimeOut, SWIG_POINTER_NEW | 0 );
return resultobj; return resultobj;
fail: fail:
...@@ -3472,7 +3466,7 @@ fail: ...@@ -3472,7 +3466,7 @@ fail:
SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_UTimeOut'.\n" SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_UTimeOut'.\n"
" Possible C/C++ prototypes are:\n" " Possible C/C++ prototypes are:\n"
" UTimeOut::UTimeOut()\n" " UTimeOut::UTimeOut()\n"
" UTimeOut::UTimeOut(std::string const)\n"); " UTimeOut::UTimeOut(std::string const &)\n");
return 0; return 0;
} }
...@@ -3520,27 +3514,22 @@ fail: ...@@ -3520,27 +3514,22 @@ fail:
SWIGINTERN PyObject *_wrap_new_USysError__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { SWIGINTERN PyObject *_wrap_new_USysError__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0; PyObject *resultobj = 0;
std::string arg1 ; std::string *arg1 = 0 ;
void *argp1 ; void *argp1 = 0 ;
int res1 = 0 ; int res1 = 0 ;
PyObject * obj0 = 0 ; PyObject * obj0 = 0 ;
USysError *result = 0 ; USysError *result = 0 ;
if (!PyArg_ParseTuple(args,(char *)"O:new_USysError",&obj0)) SWIG_fail; if (!PyArg_ParseTuple(args,(char *)"O:new_USysError",&obj0)) SWIG_fail;
{ res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__string, 0 | 0);
res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__string, 0 | 0); if (!SWIG_IsOK(res1)) {
if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_USysError" "', argument " "1"" of type '" "std::string const &""'");
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_USysError" "', argument " "1"" of type '" "std::string const""'"); }
} if (!argp1) {
if (!argp1) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_USysError" "', argument " "1"" of type '" "std::string const &""'");
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_USysError" "', argument " "1"" of type '" "std::string const""'");
} else {
std::string * temp = reinterpret_cast< std::string * >(argp1);
arg1 = *temp;
if (SWIG_IsNewObj(res1)) delete temp;
}
} }
result = (USysError *)new USysError(arg1); arg1 = reinterpret_cast< std::string * >(argp1);
result = (USysError *)new USysError((std::string const &)*arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_USysError, SWIG_POINTER_NEW | 0 ); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_USysError, SWIG_POINTER_NEW | 0 );
return resultobj; return resultobj;
fail: fail:
...@@ -3574,7 +3563,7 @@ fail: ...@@ -3574,7 +3563,7 @@ fail:
SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_USysError'.\n" SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_USysError'.\n"
" Possible C/C++ prototypes are:\n" " Possible C/C++ prototypes are:\n"
" USysError::USysError()\n" " USysError::USysError()\n"
" USysError::USysError(std::string const)\n"); " USysError::USysError(std::string const &)\n");
return 0; return 0;
} }
...@@ -3728,7 +3717,6 @@ SWIG_InitializeModule(void *clientdata) { ...@@ -3728,7 +3717,6 @@ SWIG_InitializeModule(void *clientdata) {
size_t i; size_t i;
swig_module_info *module_head, *iter; swig_module_info *module_head, *iter;
int found, init; int found, init;
(void *)clientdata;
/* check to see if the circular list has been setup, if not, set it up */ /* check to see if the circular list has been setup, if not, set it up */
if (swig_module.next==0) { if (swig_module.next==0) {
......
...@@ -64,7 +64,7 @@ long UInterface::getValue( long id )throw(UException) ...@@ -64,7 +64,7 @@ long UInterface::getValue( long id )throw(UException)
} }
catch( UException& ex ) catch( UException& ex )
{ {
throw ex; throw;
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
{ {
...@@ -114,7 +114,7 @@ void UInterface::setValue( long id, long val )throw(UException) ...@@ -114,7 +114,7 @@ void UInterface::setValue( long id, long val )throw(UException)
} }
catch( UException& ex ) catch( UException& ex )
{ {
throw ex; throw;
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
{ {
......
...@@ -11,7 +11,7 @@ namespace UTypes ...@@ -11,7 +11,7 @@ namespace UTypes
{ {
static const int max = 20; static const int max = 20;
Params():argc(0){} Params():argc(0){ memset(argv,0,sizeof(argv)); }
bool add( char* s ) bool add( char* s )
{ {
......
# This file was automatically generated by SWIG (http://www.swig.org). # This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.8 # Version 2.0.9
# #
# Do not make changes to this file unless you know what you are doing--modify # Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead. # the SWIG interface file instead.
......
...@@ -209,7 +209,7 @@ void ModbusClient::fileTransfer( ModbusAddr addr, ModbusData numfile, ...@@ -209,7 +209,7 @@ void ModbusClient::fileTransfer( ModbusAddr addr, ModbusData numfile,
mbErrCode res = erNoError; mbErrCode res = erNoError;
FILE* fdsave = fopen(save2filename,"w"); FILE* fdsave = fopen(save2filename,"w");
if( fdsave <= 0 ) if( fdsave == NULL )
{ {
if( dlog.debugging(Debug::WARN) ) if( dlog.debugging(Debug::WARN) )
dlog[Debug::WARN] << "(fileTransfer): fopen '" dlog[Debug::WARN] << "(fileTransfer): fopen '"
......
...@@ -949,7 +949,7 @@ ModbusMessage ReadOutputRetMessage::transport_msg() ...@@ -949,7 +949,7 @@ ModbusMessage ReadOutputRetMessage::transport_msg()
// копируем // копируем
memcpy(&(mm.data[ind]),dtmp,bcnt); memcpy(&(mm.data[ind]),dtmp,bcnt);
delete dtmp; delete[] dtmp;
ind+=bcnt; ind+=bcnt;
...@@ -1151,7 +1151,7 @@ ModbusMessage ReadInputRetMessage::transport_msg() ...@@ -1151,7 +1151,7 @@ ModbusMessage ReadInputRetMessage::transport_msg()
// копируем // копируем
memcpy(&(mm.data[ind]),dtmp,bcnt); memcpy(&(mm.data[ind]),dtmp,bcnt);
delete dtmp; delete[] dtmp;
ind+=bcnt; ind+=bcnt;
...@@ -1264,7 +1264,7 @@ ModbusMessage ForceCoilsMessage::transport_msg() ...@@ -1264,7 +1264,7 @@ ModbusMessage ForceCoilsMessage::transport_msg()
// копируем данные // копируем данные
memcpy(&(mm.data[ind]),dtmp,bcnt); memcpy(&(mm.data[ind]),dtmp,bcnt);
delete dtmp; delete[] dtmp;
ind+=bcnt; ind+=bcnt;
...@@ -1509,7 +1509,7 @@ ModbusMessage WriteOutputMessage::transport_msg() ...@@ -1509,7 +1509,7 @@ ModbusMessage WriteOutputMessage::transport_msg()
// копируем данные // копируем данные
memcpy(&(mm.data[ind]),dtmp,bcnt); memcpy(&(mm.data[ind]),dtmp,bcnt);
delete dtmp; delete[] dtmp;
ind+=bcnt; ind+=bcnt;
...@@ -2156,7 +2156,7 @@ ModbusMessage JournalCommandRetMessage::transport_msg() ...@@ -2156,7 +2156,7 @@ ModbusMessage JournalCommandRetMessage::transport_msg()
// копируем // копируем
memcpy(&(mm.data[ind]),dtmp,bcnt); memcpy(&(mm.data[ind]),dtmp,bcnt);
delete dtmp; delete[] dtmp;
ind += bcnt; ind += bcnt;
......
...@@ -972,7 +972,7 @@ ModbusMessage ReadOutputRetMessage::transport_msg() ...@@ -972,7 +972,7 @@ ModbusMessage ReadOutputRetMessage::transport_msg()
// копируем // копируем
memcpy(&(mm.data[ind]),dtmp,bcnt); memcpy(&(mm.data[ind]),dtmp,bcnt);
delete dtmp; delete[] dtmp;
ind+=bcnt; ind+=bcnt;
...@@ -1183,7 +1183,7 @@ ModbusMessage ReadInputRetMessage::transport_msg() ...@@ -1183,7 +1183,7 @@ ModbusMessage ReadInputRetMessage::transport_msg()
// копируем // копируем
memcpy(&(mm.data[ind]),dtmp,bcnt); memcpy(&(mm.data[ind]),dtmp,bcnt);
delete dtmp; delete[] dtmp;
ind+=bcnt; ind+=bcnt;
...@@ -1547,7 +1547,7 @@ ModbusMessage WriteOutputMessage::transport_msg() ...@@ -1547,7 +1547,7 @@ ModbusMessage WriteOutputMessage::transport_msg()
// копируем данные // копируем данные
memcpy(&(mm.data[ind]),dtmp,bcnt); memcpy(&(mm.data[ind]),dtmp,bcnt);
delete dtmp; delete[] dtmp;
ind+=bcnt; ind+=bcnt;
...@@ -2250,7 +2250,7 @@ ModbusMessage DiagnosticMessage::transport_msg() ...@@ -2250,7 +2250,7 @@ ModbusMessage DiagnosticMessage::transport_msg()
// копируем // копируем
memcpy(&(mm.data[ind]),dtmp,sizeof(ModbusData)*count); memcpy(&(mm.data[ind]),dtmp,sizeof(ModbusData)*count);
delete dtmp; delete[] dtmp;
ind+=sizeof(ModbusData)*count; ind+=sizeof(ModbusData)*count;
...@@ -2745,7 +2745,7 @@ ModbusMessage JournalCommandRetMessage::transport_msg() ...@@ -2745,7 +2745,7 @@ ModbusMessage JournalCommandRetMessage::transport_msg()
// копируем // копируем
memcpy(&(mm.data[ind]),dtmp,bcnt); memcpy(&(mm.data[ind]),dtmp,bcnt);
delete dtmp; delete[] dtmp;
ind += bcnt; ind += bcnt;
......
...@@ -202,7 +202,7 @@ namespace ORepHelpers ...@@ -202,7 +202,7 @@ namespace ORepHelpers
* \param fname - полное имя включающее в себя путь ("Root/Section1/name|Node:Alias") * \param fname - полное имя включающее в себя путь ("Root/Section1/name|Node:Alias")
* \param brk - используемый символ разделитель * \param brk - используемый символ разделитель
*/ */
const string getShortName( const string& fname, const std::string brk ) const string getShortName( const string& fname, const std::string& brk )
{ {
/* /*
string::size_type pos = fname.rfind(brk); string::size_type pos = fname.rfind(brk);
...@@ -232,7 +232,7 @@ namespace ORepHelpers ...@@ -232,7 +232,7 @@ namespace ORepHelpers
* \param brk - используемый символ разделитель * \param brk - используемый символ разделитель
* \note Функция возвращает путь без последнего символа разделителя ("Root/Section1/name" -> "Root/Section1") * \note Функция возвращает путь без последнего символа разделителя ("Root/Section1/name" -> "Root/Section1")
*/ */
const string getSectionName( const string& fullName, const std::string brk ) const string getSectionName( const string& fullName, const std::string& brk )
{ {
string::size_type pos = fullName.rfind(brk); string::size_type pos = fullName.rfind(brk);
if( pos == string::npos ) if( pos == string::npos )
......
...@@ -339,7 +339,7 @@ struct CInfo ...@@ -339,7 +339,7 @@ struct CInfo
if( value != mi.value ) if( value != mi.value )
return value < mi.value; return value < mi.value;
if( time != time ) if( time != mi.time )
return time < mi.time; return time < mi.time;
return time_usec < mi.time_usec; return time_usec < mi.time_usec;
......
...@@ -47,8 +47,8 @@ using namespace std; ...@@ -47,8 +47,8 @@ using namespace std;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
static const string UniSetDefaultPort = "2809"; static const string UniSetDefaultPort = "2809";
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
static ostream& print_help( ostream& os, int width, const string cmd, static ostream& print_help( ostream& os, int width, const string& cmd,
const string help, const string tab="" ) const string& help, const string& tab="" )
{ {
// чтобы не менчять параметры основного потока // чтобы не менчять параметры основного потока
// создаём свой stream... // создаём свой stream...
...@@ -256,7 +256,7 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -256,7 +256,7 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
catch(Exception& ex ) catch(Exception& ex )
{ {
unideb[Debug::CRIT] << "(Configuration:init): INIT FAILED! from " << fileConfName << endl; unideb[Debug::CRIT] << "(Configuration:init): INIT FAILED! from " << fileConfName << endl;
throw ex; throw;
} }
} }
} }
...@@ -1096,7 +1096,7 @@ UniversalIO::IOTypes Configuration::getIOType( const std::string name ) ...@@ -1096,7 +1096,7 @@ UniversalIO::IOTypes Configuration::getIOType( const std::string name )
return UniversalIO::UnknownIOType; return UniversalIO::UnknownIOType;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void uniset_init( int argc, const char* const* argv, const std::string xmlfile ) void uniset_init( int argc, const char* const* argv, const std::string& xmlfile )
{ {
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, xmlfile ); string confile = UniSetTypes::getArgParam( "--confile", argc, argv, xmlfile );
UniSetTypes::conf = new Configuration(argc, argv, confile); UniSetTypes::conf = new Configuration(argc, argv, confile);
......
...@@ -251,7 +251,7 @@ bool CycleStorage::create(const char* name, int byte_sz, int inf_sz, int inf_cou ...@@ -251,7 +251,7 @@ bool CycleStorage::create(const char* name, int byte_sz, int inf_sz, int inf_cou
fflush(file); fflush(file);
head=tail=-1; head=tail=-1;
delete jrn; delete[] jrn;
return true; return true;
} }
......
...@@ -46,12 +46,13 @@ bool RunLock::isLocked(const string& name) ...@@ -46,12 +46,13 @@ bool RunLock::isLocked(const string& name)
if( out ) if( out )
{ {
char ptr[10]; char ptr[10];
fscanf( out, "%s", ptr ); fscanf( out, "%9s", ptr );
DIR *d = opendir( "/proc" ); DIR *d = opendir( "/proc" );
dirent *dir; dirent *dir;
while((dir = readdir(d))) while((dir = readdir(d)))
{ {
if(!strcmp( ptr, dir->d_name )) if( !strcmp( ptr, dir->d_name ) )
{ {
// по хорошему здесь надо бы проверять // по хорошему здесь надо бы проверять
// статус на зомби // статус на зомби
...@@ -71,14 +72,16 @@ bool RunLock::isLocked(const string& name) ...@@ -71,14 +72,16 @@ bool RunLock::isLocked(const string& name)
} }
} }
*/ */
unideb[Debug::INFO] << "(RunLock): programm " << name << " already run" << endl; if( unideb.debugging(Debug::INFO) )
unideb[Debug::INFO] << "(RunLock): programm " << name << " already run" << endl;
fclose(out); fclose(out);
closedir(d); closedir(d);
return true; return true;
} }
} }
fclose(out); fclose(out);
closedir(d); closedir(d);
} }
......
...@@ -161,13 +161,11 @@ void SViewer::readSection(const string section, const string secRoot) ...@@ -161,13 +161,11 @@ void SViewer::readSection(const string section, const string secRoot)
void SViewer::getInfo( ObjectId id ) void SViewer::getInfo( ObjectId id )
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
bool c(false);
try try
{ {
try try
{ {
oref = cache.resolve(id, conf->getLocalNode()); oref = cache.resolve(id, conf->getLocalNode());
c = true;
} }
catch( NameNotFound ){} catch( NameNotFound ){}
......
...@@ -198,7 +198,7 @@ bool TableBlockStorage::open(const char* name, int byte_sz, int key_sz, int inf_ ...@@ -198,7 +198,7 @@ bool TableBlockStorage::open(const char* name, int byte_sz, int key_sz, int inf_
fread(elemPointer(i),(full_size),1,file); fread(elemPointer(i),(full_size),1,file);
if(elemPointer(i)->count>max) max=elemPointer(i)->count; if(elemPointer(i)->count>max) max=elemPointer(i)->count;
} }
delete t; delete[] t;
return true; return true;
} }
......
...@@ -40,6 +40,7 @@ TableStorage::TableStorage( const char* name, int inf_sz, int sz, int seek ): ...@@ -40,6 +40,7 @@ TableStorage::TableStorage( const char* name, int inf_sz, int sz, int seek ):
if(file==NULL) if(file==NULL)
{ {
file = fopen(name,"w"); file = fopen(name,"w");
memset(t,0,sizeof(*t));
for(int i=0;i<size;i++) fwrite(t,(sizeof(TableStorageElem)+inf_size),1,file); for(int i=0;i<size;i++) fwrite(t,(sizeof(TableStorageElem)+inf_size),1,file);
fclose(file); fclose(file);
file = fopen(name,"r+"); file = fopen(name,"r+");
...@@ -102,6 +103,8 @@ TableStorage::TableStorage( const char* name, int inf_sz, int sz, int seek ): ...@@ -102,6 +103,8 @@ TableStorage::TableStorage( const char* name, int inf_sz, int sz, int seek ):
else head=size-1; else head=size-1;
} }
} }
free(t);
} }
TableStorage::~TableStorage() TableStorage::~TableStorage()
...@@ -125,6 +128,7 @@ int TableStorage::addRow(char* key, char* value) ...@@ -125,6 +128,7 @@ int TableStorage::addRow(char* key, char* value)
*((char*)(tbl)+sizeof(TableStorageElem)+k)=*(value+k); *((char*)(tbl)+sizeof(TableStorageElem)+k)=*(value+k);
fwrite(tbl,(sizeof(TableStorageElem)+inf_size),1,file); fwrite(tbl,(sizeof(TableStorageElem)+inf_size),1,file);
head=0; head=0;
free(tbl);
return 0; return 0;
} }
fseek(file,seekpos+head*(sizeof(TableStorageElem)+inf_size),0); fseek(file,seekpos+head*(sizeof(TableStorageElem)+inf_size),0);
...@@ -139,6 +143,7 @@ int TableStorage::addRow(char* key, char* value) ...@@ -139,6 +143,7 @@ int TableStorage::addRow(char* key, char* value)
*((char*)(tbl)+sizeof(TableStorageElem)+k)=*(value+k); *((char*)(tbl)+sizeof(TableStorageElem)+k)=*(value+k);
fseek(file,seekpos+i*(sizeof(TableStorageElem)+inf_size),0); fseek(file,seekpos+i*(sizeof(TableStorageElem)+inf_size),0);
fwrite(tbl,(sizeof(TableStorageElem)+inf_size),1,file); fwrite(tbl,(sizeof(TableStorageElem)+inf_size),1,file);
free(tbl);
return 0; return 0;
} }
j++; j++;
...@@ -178,9 +183,12 @@ int TableStorage::addRow(char* key, char* value) ...@@ -178,9 +183,12 @@ int TableStorage::addRow(char* key, char* value)
fwrite(tbl,(sizeof(TableStorageElem)+inf_size),1,file); fwrite(tbl,(sizeof(TableStorageElem)+inf_size),1,file);
head++; head++;
if(head>=size) head=0; if(head>=size) head=0;
free(tbl);
return 0; return 0;
} }
} }
free(tbl);
return 1; return 1;
} }
...@@ -203,6 +211,7 @@ int TableStorage::delRow(char* key) ...@@ -203,6 +211,7 @@ int TableStorage::delRow(char* key)
else tbl->status=5; else tbl->status=5;
fseek(file,seekpos+j*(sizeof(TableStorageElem)+inf_size),0); fseek(file,seekpos+j*(sizeof(TableStorageElem)+inf_size),0);
fwrite(tbl,(sizeof(TableStorageElem)+inf_size),1,file); fwrite(tbl,(sizeof(TableStorageElem)+inf_size),1,file);
free(tbl);
return 0; return 0;
} }
j++; j++;
...@@ -213,6 +222,8 @@ int TableStorage::delRow(char* key) ...@@ -213,6 +222,8 @@ int TableStorage::delRow(char* key)
} }
} }
} }
free(tbl);
return 1; return 1;
} }
...@@ -230,10 +241,12 @@ char* TableStorage::findKeyValue(char* key, char* val) ...@@ -230,10 +241,12 @@ char* TableStorage::findKeyValue(char* key, char* val)
{ {
for(k=0;k<inf_size;k++) for(k=0;k<inf_size;k++)
*(val+k)=*((char*)(tbl)+sizeof(TableStorageElem)+k); *(val+k)=*((char*)(tbl)+sizeof(TableStorageElem)+k);
free(tbl);
return val; return val;
} }
} }
} }
free(tbl);
return 0; return 0;
} }
...@@ -179,7 +179,9 @@ xmlNode* UniXML::copyNode(xmlNode* node, int recursive) ...@@ -179,7 +179,9 @@ xmlNode* UniXML::copyNode(xmlNode* node, int recursive)
\todo "Нужно тест написать на copyNode" \todo "Нужно тест написать на copyNode"
*/ */
copynode->properties = ::xmlCopyPropList(NULL,node->properties); if( copynode )
copynode->properties = ::xmlCopyPropList(NULL,node->properties);
if( copynode != 0 && node->parent ) if( copynode != 0 && node->parent )
{ {
xmlNode* newnode = ::xmlNewChild(node->parent, NULL, (const xmlChar*)"", (const xmlChar*)"" ); xmlNode* newnode = ::xmlNewChild(node->parent, NULL, (const xmlChar*)"", (const xmlChar*)"" );
...@@ -411,7 +413,7 @@ int UniXML_iterator::getPIntProp( const string name, int def ) const ...@@ -411,7 +413,7 @@ int UniXML_iterator::getPIntProp( const string name, int def ) const
return i; return i;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void UniXML_iterator::setProp( const string name, const string text ) void UniXML_iterator::setProp( const string name, const string text )
{ {
UniXML::setProp(curNode, name, text); UniXML::setProp(curNode, name, text);
...@@ -420,7 +422,7 @@ void UniXML_iterator::setProp( const string name, const string text ) ...@@ -420,7 +422,7 @@ void UniXML_iterator::setProp( const string name, const string text )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool UniXML_iterator::findName( const std::string node, const std::string searchname ) bool UniXML_iterator::findName( const std::string node, const std::string searchname )
{ {
while( find(node) ) while( this->find(node) )
{ {
if ( searchname == getProp("name") ) if ( searchname == getProp("name") )
return true; return true;
......
...@@ -95,7 +95,7 @@ bool testTable2(void) ...@@ -95,7 +95,7 @@ bool testTable2(void)
t0.addRow((char*)&i,val); t0.addRow((char*)&i,val);
if(t.getCurBlock()!=0) if(t.getCurBlock()!=0)
{ {
delete val; delete[] val;
return false; return false;
} }
for(i=1;i<11;i++) for(i=1;i<11;i++)
...@@ -105,7 +105,7 @@ bool testTable2(void) ...@@ -105,7 +105,7 @@ bool testTable2(void)
} }
if(t.getCurBlock()!=0) if(t.getCurBlock()!=0)
{ {
delete val; delete[] val;
return false; return false;
} }
for(i=1;i<20;i++) for(i=1;i<20;i++)
...@@ -113,14 +113,14 @@ bool testTable2(void) ...@@ -113,14 +113,14 @@ bool testTable2(void)
if(t.findKeyValue(&i,val)!=0) printf("%s, ",val); if(t.findKeyValue(&i,val)!=0) printf("%s, ",val);
if(val[0]==0) if(val[0]==0)
{ {
delete val; delete[] val;
return false; return false;
} }
} }
printf("\n"); printf("\n");
if(t.getCurBlock()!=0) if(t.getCurBlock()!=0)
{ {
delete val; delete[] val;
return false; return false;
} }
for(i=1;i<8;i++) for(i=1;i<8;i++)
...@@ -140,20 +140,20 @@ bool testTable2(void) ...@@ -140,20 +140,20 @@ bool testTable2(void)
printf("%s, ",val); printf("%s, ",val);
if((i > 7)&&(i <11)) if((i > 7)&&(i <11))
{ {
delete val; delete[] val;
return false; return false;
} }
} }
if((val[0] == 0)&&(i < 8)) if((val[0] == 0)&&(i < 8))
{ {
delete val; delete[] val;
return false; return false;
} }
} }
printf("\nrewriting 3-10 elements with values=keys+40\n"); printf("\nrewriting 3-10 elements with values=keys+40\n");
if(t.getCurBlock()!=0) if(t.getCurBlock()!=0)
{ {
delete val; delete[] val;
return false; return false;
} }
for(i=3;i<11;i++) for(i=3;i<11;i++)
...@@ -166,18 +166,18 @@ bool testTable2(void) ...@@ -166,18 +166,18 @@ bool testTable2(void)
if(t.findKeyValue(&i,val)!=0) printf("%s, ",val); if(t.findKeyValue(&i,val)!=0) printf("%s, ",val);
if((UniSetTypes::uni_atoi(val) != i+40) && (i>2) && (i<11)) if((UniSetTypes::uni_atoi(val) != i+40) && (i>2) && (i<11))
{ {
delete val; delete[] val;
return false; return false;
} }
if((UniSetTypes::uni_atoi(val) != i+10) && (i<3)) if((UniSetTypes::uni_atoi(val) != i+10) && (i<3))
{ {
delete val; delete[] val;
return false; return false;
} }
} }
if(t.getCurBlock()!=0) if(t.getCurBlock()!=0)
{ {
delete val; delete[] val;
return false; return false;
} }
...@@ -192,7 +192,7 @@ bool testTable2(void) ...@@ -192,7 +192,7 @@ bool testTable2(void)
} }
if(t.getCurBlock()!=1) if(t.getCurBlock()!=1)
{ {
delete val; delete[] val;
return false; return false;
} }
printf("after reopen:\n"); printf("after reopen:\n");
...@@ -203,10 +203,10 @@ bool testTable2(void) ...@@ -203,10 +203,10 @@ bool testTable2(void)
} }
if(t.getCurBlock()!=1) if(t.getCurBlock()!=1)
{ {
delete val; delete[] val;
return false; return false;
} }
delete val; delete[] val;
return true; return true;
} }
...@@ -219,7 +219,7 @@ bool reOpen() ...@@ -219,7 +219,7 @@ bool reOpen()
if(!j.open("big_file.test",bj_size,30,33000,seek)) if(!j.open("big_file.test",bj_size,30,33000,seek))
{ {
printf("Reopen file error\n"); printf("Reopen file error\n");
delete str; delete[] str;
return false; return false;
} }
for(i=0;i<20;i++) for(i=0;i<20;i++)
...@@ -230,7 +230,7 @@ bool reOpen() ...@@ -230,7 +230,7 @@ bool reOpen()
k++; k++;
} }
} }
delete str; delete[] str;
if(k != 10) if(k != 10)
return false; return false;
return true; return true;
...@@ -262,7 +262,7 @@ bool testJournal1(void) ...@@ -262,7 +262,7 @@ bool testJournal1(void)
} }
if(k < 30) if(k < 30)
{ {
delete str; delete[] str;
return false; return false;
} }
k = 0; k = 0;
...@@ -276,12 +276,12 @@ bool testJournal1(void) ...@@ -276,12 +276,12 @@ bool testJournal1(void)
if(t.findKeyValue((char*)&i,val)!=0) printf("%s, ",val); if(t.findKeyValue((char*)&i,val)!=0) printf("%s, ",val);
if((UniSetTypes::uni_atoi(val) != i+10) && (i<3)) if((UniSetTypes::uni_atoi(val) != i+10) && (i<3))
{ {
delete val; delete[] val;
delete str; delete[] str;
return false; return false;
} }
} }
delete val; delete[] val;
printf("\nfirst 30 elements after deleting first 20:\n"); printf("\nfirst 30 elements after deleting first 20:\n");
for(i=0;i<20;i++) for(i=0;i<20;i++)
...@@ -298,7 +298,7 @@ bool testJournal1(void) ...@@ -298,7 +298,7 @@ bool testJournal1(void)
} }
if(k != 10) if(k != 10)
{ {
delete str; delete[] str;
return false; return false;
} }
k = 0; k = 0;
...@@ -319,15 +319,15 @@ bool testJournal1(void) ...@@ -319,15 +319,15 @@ bool testJournal1(void)
} }
if(k != 10) if(k != 10)
{ {
delete str; delete[] str;
return false; return false;
} }
k = 0; k = 0;
if(!reOpen()) return false; if(!reOpen()){ delete[] str; return false; };
if(!reOpen()) return false; if(!reOpen()){ delete[] str; return false; };
printf("size changed back to 32000 rows\n"); printf("size changed back to 32000 rows\n");
j.setSize(32000); j.setSize(32000);
...@@ -341,12 +341,12 @@ bool testJournal1(void) ...@@ -341,12 +341,12 @@ bool testJournal1(void)
} }
if(k != 10) if(k != 10)
{ {
delete str; delete[] str;
return false; return false;
} }
k = 0; k = 0;
delete str; delete[] str;
return true; return true;
} }
...@@ -368,7 +368,7 @@ void testJournal2(void) ...@@ -368,7 +368,7 @@ void testJournal2(void)
printf("i=%d, iterations = %d\n", i, j.getIter()); printf("i=%d, iterations = %d\n", i, j.getIter());
} }
printf("\n"); printf("\n");
delete str; delete[] str;
} }
......
...@@ -8,7 +8,7 @@ using namespace std; ...@@ -8,7 +8,7 @@ using namespace std;
#include "UniSetTypes.h" #include "UniSetTypes.h"
void check( const std::string name, const std::string true_res, const std::string your_res ) void check( const std::string& name, const std::string& true_res, const std::string& your_res )
{ {
cout<<name<<endl; cout<<name<<endl;
cout<<"Correct result: "<<true_res<<endl; cout<<"Correct result: "<<true_res<<endl;
......
...@@ -7,8 +7,15 @@ using namespace std; ...@@ -7,8 +7,15 @@ using namespace std;
PassiveTimer pt(1000); PassiveTimer pt(1000);
void func( const std::string& s1 )
{
}
int main() int main()
{ {
func("test");
PassiveTimer pt1(5000); PassiveTimer pt1(5000);
cout << " pt1.getInterval()=" << pt1.getInterval() << " TEST: " << ((pt1.getInterval()==5000) ? "OK" : "FAILED") << endl; cout << " pt1.getInterval()=" << pt1.getInterval() << " TEST: " << ((pt1.getInterval()==5000) ? "OK" : "FAILED") << endl;
......
...@@ -12,7 +12,7 @@ uniset_mutex m; ...@@ -12,7 +12,7 @@ uniset_mutex m;
class MyClass class MyClass
{ {
public: public:
MyClass( const std::string name ): nm(name) MyClass( const std::string& name ): nm(name)
{ {
thr = new ThreadCreator<MyClass>(this, &MyClass::thread); thr = new ThreadCreator<MyClass>(this, &MyClass::thread);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment