summaryrefslogtreecommitdiffstats
path: root/searchcorespi
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 /searchcorespi
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 'searchcorespi')
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/eventlogger.cpp8
-rw-r--r--searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp3
2 files changed, 6 insertions, 5 deletions
diff --git a/searchcorespi/src/vespa/searchcorespi/index/eventlogger.cpp b/searchcorespi/src/vespa/searchcorespi/index/eventlogger.cpp
index 9d824d69f93..cf1daf983b3 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/eventlogger.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/eventlogger.cpp
@@ -19,7 +19,7 @@ EventLogger::diskIndexLoadStart(const vespalib::string &indexDir)
jstr.appendKey("input");
LogUtil::logDir(jstr, indexDir, 6);
jstr.endObject();
- EV_STATE("diskindex.load.start", jstr.toString().c_str());
+ EV_STATE("diskindex.load.start", jstr.toString().data());
}
void
@@ -32,7 +32,7 @@ EventLogger::diskIndexLoadComplete(const vespalib::string &indexDir,
jstr.appendKey("input");
LogUtil::logDir(jstr, indexDir, 6);
jstr.endObject();
- EV_STATE("diskindex.load.complete", jstr.toString().c_str());
+ EV_STATE("diskindex.load.complete", jstr.toString().data());
}
void
@@ -50,7 +50,7 @@ EventLogger::diskFusionStart(const std::vector<vespalib::string> &sources,
jstr.appendKey("output");
LogUtil::logDir(jstr, fusionDir, 6);
jstr.endObject();
- EV_STATE("fusion.start", jstr.toString().c_str());
+ EV_STATE("fusion.start", jstr.toString().data());
}
void
@@ -63,7 +63,7 @@ EventLogger::diskFusionComplete(const vespalib::string &fusionDir,
jstr.appendKey("output");
LogUtil::logDir(jstr, fusionDir, 6);
jstr.endObject();
- EV_STATE("fusion.complete", jstr.toString().c_str());
+ EV_STATE("fusion.complete", jstr.toString().data());
}
}
diff --git a/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp b/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp
index 1dac8c7aafd..3180f7ed29d 100644
--- a/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/plugin/factoryloader.cpp
@@ -25,7 +25,8 @@ FactoryLoader::create(const stringref & factory)
const FastOS_DynamicLibrary & lib = *_libraries.get(factory);
FuncT registrationMethod = reinterpret_cast<FuncT>(lib.GetSymbol("createIndexManagerFactory"));
if (registrationMethod == NULL) {
- throw IllegalArgumentException(make_string("Failed locating symbol 'createIndexManagerFactory' in library '%s' for factory '%s'.", lib.GetLibName(), factory.c_str()));
+ throw IllegalArgumentException(make_string("Failed locating symbol 'createIndexManagerFactory' in library '%s' for factory '%s'.",
+ lib.GetLibName(), vespalib::string(factory).c_str()));
}
return IIndexManagerFactory::UP(registrationMethod());
}