You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by GitBox <gi...@apache.org> on 2020/04/06 07:40:54 UTC
[GitHub] [celix] pnoltes commented on a change in pull request #186: Cleanup
dm interface
pnoltes commented on a change in pull request #186: Cleanup dm interface
URL: https://github.com/apache/celix/pull/186#discussion_r403886608
##########
File path: libs/framework/include/celix/dm/Component_Impl.h
##########
@@ -39,21 +39,25 @@ Component<T>::~Component() {
template<class T>
template<class I>
-Component<T>& Component<T>::addInterfaceWithName(const std::string serviceName, const std::string version, const Properties properties) {
+Component<T>& Component<T>::addInterfaceWithName(const std::string &serviceName, const std::string &version, const Properties &properties) {
if (!serviceName.empty()) {
//setup c properties
celix_properties_t *cProperties = properties_create();
properties_set(cProperties, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE);
for (const auto& pair : properties) {
- properties_set(cProperties, (char *) pair.first.c_str(), (char *) pair.second.c_str());
+ char *key = nullptr;
+ char *value = nullptr;
+ copyString(pair.first, &key);
+ copyString(pair.second, &value);
+ properties_set(cProperties, key, value);
Review comment:
note that properties_set does een copy of the provided key/value, so now you have a double copy
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services