Skip to content

Commit

Permalink
Merge pull request #50 from bpcampbe/TrimBuffer
Browse files Browse the repository at this point in the history
Add CChan::TrimBuffer and have SetBufferCount call it.
  • Loading branch information
psychon committed Jun 7, 2011
2 parents ea19e3f + c3a15bf commit f6113b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Chan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions Chan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f6113b3

Please sign in to comment.