]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2369] Use createSreamName() from #2371 instead of using sprintf()
authorMukund Sivaraman <muks@isc.org>
Wed, 31 Oct 2012 07:34:03 +0000 (13:04 +0530)
committerMukund Sivaraman <muks@isc.org>
Wed, 31 Oct 2012 07:34:03 +0000 (13:04 +0530)
src/lib/dns/inputsource.cc

index f52f493db7fde38ace7b2a280b200d796644e33c..051705b9b78c067f64ce87cf67bbca0a07768b5c 100644 (file)
 
 #include <dns/inputsource.h>
 
-#include <cstdio>
-
-using namespace std;
-
 namespace isc {
 namespace dns {
 namespace master_lexer_internal {
 
+namespace { // unnamed namespace
+
+std::string
+createStreamName(std::istream& input_stream) {
+     std::stringstream ss;
+     ss << "stream-" << &input_stream;
+     return (ss.str());
+}
+
+} // end of unnamed namespace
+
 InputSource::InputSource(std::istream& input_stream) :
     at_eof_(false),
     line_(1),
     saved_line_(line_),
     buffer_pos_(buffer_.size()),
+    name_(createStreamName(input_stream)),
     input_(input_stream)
-{
-    char buf[FILENAME_MAX];
-    snprintf(buf, sizeof(buf), "stream-%p", &input_stream);
-    name_ = buf;
-}
+{}
 
 InputSource::InputSource(const char* filename) :
     at_eof_(false),
@@ -42,7 +46,7 @@ InputSource::InputSource(const char* filename) :
     name_(filename),
     input_(file_stream_)
 {
-    file_stream_.open(filename, fstream::in);
+    file_stream_.open(filename, std::fstream::in);
 }
 
 InputSource::~InputSource()