aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@oath.com>2018-07-25 14:24:21 +0000
committerTor Brede Vekterli <vekterli@oath.com>2018-07-25 14:24:21 +0000
commit12c8f3005e202b31a8e0ff3816ce9d714a269046 (patch)
treea5d9ba0eedc49df2cea2dbdfea677c4c37ed3775 /config
parente3af3d215feb1e416b27b92bbf421dde281f3a09 (diff)
Remove stringref::c_str()
The expected semantics of c_str() (a null-terminated string) cannot be satisfied with a string reference, so remove the function entirely to prevent people from using it in buggy ways. Replaces c_str() with data() in places where it is presumed safe, otherwise constructs temporary string instances. Certain callsites have been de-stringref'd in favor of regular strings, in particular where C APIs have been transitively called. The vast majority of these were called with string parameters anyway, so should not cause much extra allocation.
Diffstat (limited to 'config')
-rw-r--r--config/src/vespa/config/common/configparser.cpp2
-rw-r--r--config/src/vespa/config/common/configparser.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/config/src/vespa/config/common/configparser.cpp b/config/src/vespa/config/common/configparser.cpp
index 6784f0793e9..4d9eac41af6 100644
--- a/config/src/vespa/config/common/configparser.cpp
+++ b/config/src/vespa/config/common/configparser.cpp
@@ -14,7 +14,7 @@ void ConfigParser::throwNoDefaultValue(const vespalib::stringref & key) {
}
vespalib::string
-ConfigParser::deQuote(const vespalib::stringref & source)
+ConfigParser::deQuote(const vespalib::string & source)
{
const char *src = source.c_str();
const char *s = src;
diff --git a/config/src/vespa/config/common/configparser.h b/config/src/vespa/config/common/configparser.h
index 2f6cdd9cf39..77b5bf7ddaa 100644
--- a/config/src/vespa/config/common/configparser.h
+++ b/config/src/vespa/config/common/configparser.h
@@ -23,7 +23,7 @@ private:
static std::vector<vsvector> splitArray( const vsvector & config);
static std::map<vespalib::string, vsvector> splitMap( const vsvector & config);
- static vespalib::string deQuote(const vespalib::stringref & source);
+ static vespalib::string deQuote(const vespalib::string & source);
static void throwNoDefaultValue(const vespalib::stringref & key);
template<typename T>