Permalink
Browse files

gateway: fixes memory leak problem on binary protocol

  • Loading branch information...
frsyuki committed May 22, 2010
1 parent 5c20eec commit 0c429f8de371d829e3dc198bed664fe62955ef6a
Showing with 9 additions and 1 deletion.
  1. +3 −0 src/mp/stream_buffer.h
  2. +6 −1 src/mp/stream_buffer_impl.h
View
@@ -59,6 +59,9 @@ class stream_buffer {
std::vector<void*> m_array;
struct each_incr;
struct each_decr;
+ private:
+ void move(void* d);
+ friend class stream_buffer;
};
reference* release();
@@ -88,6 +88,11 @@ inline void stream_buffer::reference::push(void* d)
incr_count(d);
}
+inline void stream_buffer::reference::move(void* d)
+{
+ m_array.push_back(d);
+}
+
inline void stream_buffer::reference::swap(reference& x)
{
m_array.swap(x.m_array);
@@ -200,7 +205,7 @@ inline void stream_buffer::expand_buffer(size_t len, size_t initial_buffer_size)
init_count(tmp);
try {
- m_ref.push(m_buffer);
+ m_ref.move(m_buffer);
} catch (...) { free(tmp); throw; }
memcpy(tmp+sizeof(count_t), m_buffer+m_off, not_used);

0 comments on commit 0c429f8

Please sign in to comment.