Skip to content
Browse files

Merge pull request #50 from bpcampbe/TrimBuffer

Add CChan::TrimBuffer and have SetBufferCount call it.
  • Loading branch information...
2 parents ea19e3f + c3a15bf commit f6113b322dbb32af6b27b72e3a557e46acf20ffb @psychon psychon committed Jun 7, 2011
Showing with 8 additions and 0 deletions.
  1. +7 −0 Chan.cpp
  2. +1 −0 Chan.h
View
7 Chan.cpp
@@ -112,6 +112,7 @@ bool CChan::SetBufferCount(unsigned int u, bool bForce) {
if (!bForce && u > CZNC::Get().GetMaxBufferSize())
return false;
m_uBufferCount = u;
+ TrimBuffer(m_uBufferCount);
return true;
}
@@ -534,6 +535,12 @@ void CChan::ClearBuffer() {
m_vsBuffer.clear();
}
+void CChan::TrimBuffer(const unsigned int uMax) {
+ if (m_vsBuffer.size() > uMax) {
+ m_vsBuffer.erase(m_vsBuffer.begin(), m_vsBuffer.begin() + (uMax - m_vsBuffer.size()));
+ }
+}
+
void CChan::SendBuffer(CClient* pClient) {
if (m_pUser && m_pUser->IsUserAttached()) {
const vector<CString>& vsBuffer = GetBuffer();
View
1 Chan.h
@@ -88,6 +88,7 @@ class CChan {
// Buffer
int AddBuffer(const CString& sLine);
void ClearBuffer();
+ void TrimBuffer(const unsigned int uMax);
void SendBuffer(CClient* pClient);
// !Buffer

0 comments on commit f6113b3

Please sign in to comment.
Something went wrong with that request. Please try again.