Permalink
Browse files

fix bad cast, trying to set non-pod field

  • Loading branch information...
erikfrey committed Aug 27, 2012
1 parent a974d6b commit 9a908f2fae05d5b4957671da937485b94692cb62
Showing with 8 additions and 9 deletions.
  1. +1 −5 include/darner/queue/queue.h
  2. +7 −4 src/queue/queue.cpp
@@ -72,11 +72,7 @@ class queue
id_type end;
size_type size;
- const std::string& str() const;
-
- private:
-
- mutable std::string buf_;
+ void str(std::string& out) const;
};
// queue methods aren't meant to be used directly. instead create an iqstream or oqstream to use it
View
@@ -88,7 +88,11 @@ void queue::push(id_type& result, const string& item)
void queue::push(id_type& result, const header_type& header)
{
- put(queue_head_.slice(), header.str());
+ std::string buf;
+
+ header.str(buf);
+
+ put(queue_head_.slice(), buf);
result = queue_head_.id++;
@@ -245,10 +249,9 @@ void queue::compact()
}
// child classes
-const string& queue::header_type::str() const
+void queue::header_type::str(std::string& out) const
{
- buf_ = string(reinterpret_cast<const char *>(this), sizeof(header_type)) + '\1' + '\0';
- return buf_;
+ out = string(reinterpret_cast<const char *>(this), sizeof(header_type)) + '\1' + '\0';
}
leveldb::Slice queue::key_type::slice() const

0 comments on commit 9a908f2

Please sign in to comment.