Use rcutils_get_env() instead of getenv() (#71) (#73)

* Use rcutils_get_env() instead of getenv() (#71)

Signed-off-by: Erik Boasson <eb@ilities.com>

* Keep includes in alphabetical order

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
eboasson 2019-11-25 20:19:14 +01:00 committed by GitHub
parent ce34664472
commit 3e7d33ba2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,6 +24,7 @@
#include <utility>
#include <regex>
#include "rcutils/get_env.h"
#include "rcutils/logging_macros.h"
#include "rcutils/strdup.h"
@ -590,9 +591,16 @@ static bool check_create_domain_locked(dds_domainid_t did, bool localhost_only)
"";
/* Emulate default behaviour of Cyclone of reading CYCLONEDDS_URI */
char * config_from_env = getenv("CYCLONEDDS_URI");
if (config_from_env != nullptr) {
const char * get_env_error;
const char * config_from_env;
if ((get_env_error = rcutils_get_env("CYCLONEDDS_URI", &config_from_env)) == nullptr) {
config += std::string(config_from_env);
} else {
RCUTILS_LOG_ERROR_NAMED("rmw_cyclonedds_cpp",
"rmw_create_node: failed to retrieve CYCLONEDDS_URI environment variable, error %s",
get_env_error);
node_gone_from_domain_locked(did);
return false;
}
if ((dom.domain_handle = dds_create_domain(did, config.c_str())) < 0) {