From 84dc06c8a1e9ffde49840aa0d74028c0b8515949 Mon Sep 17 00:00:00 2001 From: buret Date: Tue, 19 Jun 2007 11:10:30 +0000 Subject: Function SCI msg bind parameter git-svn-id: svn+ssh://pessac/svn/cesar/trunk@324 017c9cb6-072f-447c-8318-d5b54f68fe89 --- maximus/functioncall/inc/FunctionSciMsg.h | 2 +- maximus/functioncall/src/FunctionSciMsg.cpp | 18 ++++++------------ maximus/functioncall/src/FunctionSciMsgTest.cpp | 15 ++++++++------- 3 files changed, 15 insertions(+), 20 deletions(-) (limited to 'maximus/functioncall') diff --git a/maximus/functioncall/inc/FunctionSciMsg.h b/maximus/functioncall/inc/FunctionSciMsg.h index da27e9504c..926d26686e 100644 --- a/maximus/functioncall/inc/FunctionSciMsg.h +++ b/maximus/functioncall/inc/FunctionSciMsg.h @@ -145,7 +145,7 @@ public: * @param name_of_parameter_to_get * @param p_data */ - bool bindParameter ( const std::string name_of_parameter_to_get, unsigned long & data_length, void * & p_data ) const; + bool bindParameter ( const std::string name_of_parameter_to_get, unsigned long & data_length, unsigned char * & p_data ) const; /** * @return bool diff --git a/maximus/functioncall/src/FunctionSciMsg.cpp b/maximus/functioncall/src/FunctionSciMsg.cpp index d92f68a249..51d21df4f2 100644 --- a/maximus/functioncall/src/FunctionSciMsg.cpp +++ b/maximus/functioncall/src/FunctionSciMsg.cpp @@ -297,7 +297,7 @@ bool FunctionSciMsg::addParameter ( const FunctionCallParameter & function_argum // Called by user when a message is received to retrieve function parameters // -bool FunctionSciMsg::bindParameter ( const string name_of_parameter_to_get, unsigned long & data_length, void * & p_data ) const +bool FunctionSciMsg::bindParameter ( const string name_of_parameter_to_get, unsigned long & data_length, unsigned char * & p_data ) const { clog << "FunctionSciMsg::bindParameter" << endl; bool bBindParameter = false; @@ -311,26 +311,20 @@ bool FunctionSciMsg::bindParameter ( const string name_of_parameter_to_get, unsi if ( !tempParameter.getName().compare(name_of_parameter_to_get) ) { data_length = tempParameter.getValueLength(); - if (NULL != p_data) + p_data = new unsigned char [data_length+1]; // to be deleted by user + if ( (NULL != tempParameter.getValue()) && (NULL != p_data) ) { - if (NULL != tempParameter.getValue()) + for (unsigned int j=0; j FunctionSciMsg::bindParameter" << endl; CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("bindParameter failed"), - mpFunctionSciMsg->bindParameter(name, dataLength, pVoidData) ); - pData = static_cast(pVoidData); + mpFunctionSciMsg->bindParameter(name, dataLength, pData) ); // Check results // CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("bindParameterTest failed: wrong data length"), (3 == dataLength) ); CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("bindParameterTest failed: data pointer is NULL"), (NULL != pData) ); + CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("bindParameterTest failed: wrong data"), (!strcmp("123", (char*)pData)) ); // Free memory allocated into 'FunctionSciMsg::bindParameter' // - pVoidData = NULL; - pData = NULL; - + if (NULL != pData) + { + delete [] pData; + pData = NULL; + } } else { -- cgit v1.2.3