about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2012-02-09T17·27+0100
committerEelco Dolstra <e.dolstra@tudelft.nl>2012-02-09T17·27+0100
commitd5a5a83ad4fb8aba3b334039f567267a0463ee5a (patch)
treea6ce83d3c595fa987afed1c4dbbe18e82cc18322 /src/libutil
parentec2827f5fc4fc8081daacb197d40d22a5e429df4 (diff)
Use data() instead of c_str() where appropriate
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/hash.cc6
-rw-r--r--src/libutil/serialise.cc2
-rw-r--r--src/libutil/util.cc6
3 files changed, 7 insertions, 7 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc
index bbfe7847fd8a..697a6b475b13 100644
--- a/src/libutil/hash.cc
+++ b/src/libutil/hash.cc
@@ -136,7 +136,7 @@ string printHash32(const Hash & hash)
     Hash hash2(hash);
     unsigned int len = hashLength32(hash);
 
-    const char * chars = base32Chars.c_str();
+    const char * chars = base32Chars.data();
     
     string s(len, '0');
 
@@ -186,7 +186,7 @@ Hash parseHash32(HashType ht, const string & s)
 {
     Hash hash(ht);
 
-    const char * chars = base32Chars.c_str();
+    const char * chars = base32Chars.data();
 
     for (unsigned int i = 0; i < s.length(); ++i) {
         char c = s[i];
@@ -271,7 +271,7 @@ Hash hashString(HashType ht, const string & s)
     Ctx ctx;
     Hash hash(ht);
     start(ht, ctx);
-    update(ht, ctx, (const unsigned char *) s.c_str(), s.length());
+    update(ht, ctx, (const unsigned char *) s.data(), s.length());
     finish(ht, ctx, hash.hash);
     return hash;
 }
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc
index c4563ffd1212..9270806a7798 100644
--- a/src/libutil/serialise.cc
+++ b/src/libutil/serialise.cc
@@ -159,7 +159,7 @@ void writeString(const unsigned char * buf, size_t len, Sink & sink)
 
 void writeString(const string & s, Sink & sink)
 {
-    writeString((const unsigned char *) s.c_str(), s.size(), sink);
+    writeString((const unsigned char *) s.data(), s.size(), sink);
 }
 
 
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 0352754f592c..42e5519b48b0 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -236,7 +236,7 @@ void writeFile(const Path & path, const string & s)
     AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0666);
     if (fd == -1)
         throw SysError(format("opening file `%1%'") % path);
-    writeFull(fd, (unsigned char *) s.c_str(), s.size());
+    writeFull(fd, (unsigned char *) s.data(), s.size());
 }
 
 
@@ -263,7 +263,7 @@ string readLine(int fd)
 void writeLine(int fd, string s)
 {
     s += '\n';
-    writeFull(fd, (const unsigned char *) s.c_str(), s.size());
+    writeFull(fd, (const unsigned char *) s.data(), s.size());
 }
 
 
@@ -485,7 +485,7 @@ void printMsg_(Verbosity level, const format & f)
         prefix = "\033[" + escVerbosity(level) + "s";
     string s = (format("%1%%2%\n") % prefix % f.str()).str();
     try {
-        writeToStderr((const unsigned char *) s.c_str(), s.size());
+        writeToStderr((const unsigned char *) s.data(), s.size());
     } catch (SysError & e) {
         /* Ignore failing writes to stderr if we're in an exception
            handler, otherwise throw an exception.  We need to ignore