winlin

for bug#241, simplify the buffer, donot realloc it.

@@ -90,10 +90,9 @@ SrsFastBuffer::SrsFastBuffer() @@ -90,10 +90,9 @@ SrsFastBuffer::SrsFastBuffer()
90 _handler = NULL; 90 _handler = NULL;
91 #endif 91 #endif
92 92
93 - p = end = buffer = NULL;  
94 - nb_buffer = 0;  
95 -  
96 - reset_buffer(SRS_MR_SOCKET_BUFFER); 93 + nb_buffer = SRS_MR_SOCKET_BUFFER;
  94 + buffer = new char[nb_buffer];
  95 + p = end = buffer;
97 } 96 }
98 97
99 SrsFastBuffer::~SrsFastBuffer() 98 SrsFastBuffer::~SrsFastBuffer()
@@ -193,21 +192,3 @@ void SrsFastBuffer::set_merge_read(bool v, IMergeReadHandler* handler) @@ -193,21 +192,3 @@ void SrsFastBuffer::set_merge_read(bool v, IMergeReadHandler* handler)
193 } 192 }
194 #endif 193 #endif
195 194
196 -void SrsFastBuffer::reset_buffer(int size)  
197 -{  
198 - // remember the cap.  
199 - int nb_cap = end - p;  
200 -  
201 - // atleast to put the old data.  
202 - nb_buffer = srs_max(nb_cap, size);  
203 -  
204 - // copy old data to buf.  
205 - char* buf = new char[nb_buffer];  
206 - if (nb_cap > 0) {  
207 - memcpy(buf, p, nb_cap);  
208 - }  
209 -  
210 - srs_freep(buffer);  
211 - p = buffer = buf;  
212 - end = p + nb_cap;  
213 -}  
@@ -162,8 +162,6 @@ public: @@ -162,8 +162,6 @@ public:
162 */ 162 */
163 virtual void set_merge_read(bool v, IMergeReadHandler* handler); 163 virtual void set_merge_read(bool v, IMergeReadHandler* handler);
164 #endif 164 #endif
165 -private:  
166 - virtual void reset_buffer(int size);  
167 }; 165 };
168 166
169 #endif 167 #endif