diff options
author | Sebastien Gonzalve <sebastien.gonzalve@intel.com> | 2015-04-10 09:28:48 +0200 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2015-04-24 13:39:13 -0700 |
commit | 76fa9021317cc7f93f494795baf8c18f871ad3e5 (patch) | |
tree | 79c644cac6a8df878c02f209f032b49927f960a8 /parameter/StringParameter.cpp | |
parent | 316559093d972d8b7d51290103d68395bfec6064 (diff) | |
download | external_parameter-framework-76fa9021317cc7f93f494795baf8c18f871ad3e5.zip external_parameter-framework-76fa9021317cc7f93f494795baf8c18f871ad3e5.tar.gz external_parameter-framework-76fa9021317cc7f93f494795baf8c18f871ad3e5.tar.bz2 |
Change blackboard write/readString prototype
Those functions are used in one place and let the caller transform a
std::string to a char * which makes the use of alloca necessary.
Moreover, the readString cannot know if the pointer given in input
points to a buffer with enough space, making it dangerous.
This patch reworks the API so that write/readString() get std::string
and lets the implementation play with char *. This also allows to get
rid of alloca() use which is quite dangerous.
Change-Id: I973e4987278289bb914c4e194b86e924a1c88a6d
Signed-off-by: Sebastien Gonzalve <sebastien.gonzalve@intel.com>
Diffstat (limited to 'parameter/StringParameter.cpp')
-rw-r--r-- | parameter/StringParameter.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/parameter/StringParameter.cpp b/parameter/StringParameter.cpp index cb13e9b..8ba5b16 100644 --- a/parameter/StringParameter.cpp +++ b/parameter/StringParameter.cpp @@ -32,7 +32,6 @@ #include "ParameterAccessContext.h" #include "ConfigurationAccessContext.h" #include "ParameterBlackboard.h" -#include <alloca.h> #define base CBaseParameter @@ -79,19 +78,12 @@ bool CStringParameter::doSetValue(const string& strValue, uint32_t uiOffset, CPa // Write blackboard CParameterBlackboard* pBlackboard = parameterAccessContext.getParameterBlackboard(); - pBlackboard->writeString(strValue.c_str(), uiOffset); + pBlackboard->writeString(strValue, uiOffset); return true; } void CStringParameter::doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const { - char* pcValue = (char*)alloca(getSize()); - - // Read blackboard - const CParameterBlackboard* pBlackboard = parameterAccessContext.getParameterBlackboard(); - - pBlackboard->readString(pcValue, uiOffset); - - strValue = pcValue; + parameterAccessContext.getParameterBlackboard()->readString(strValue, uiOffset); } |