/* * Buffer.cpp * * Created on: 27.01.2010 * Author: adamczew */ #include "Buffer.h" #include "Logger.h" #include // sysconf(3) namespace pexor { Buffer::Buffer(size_t bytes) : fSize(bytes), fUsedSize(0), fData(0) { fErrorIndices.clear(); } Buffer::~Buffer() { } size_t Buffer::NextPageSize(size_t bytes) { int pagesize=sysconf( _SC_PAGE_SIZE ); int rest=bytes % pagesize; if(rest) { bytes=bytes-rest + pagesize; PexorDebug("Buffer::NextPageSize expanding to %d bytes.\n",bytes); } return bytes; } bool Buffer::operator==(const pexor::Buffer &other) { fErrorIndices.clear(); if(this==&other) return true; int buflen=other.Length(); if (buflen!=Length()) return false; bool isequal=true; const pexor::Buffer& myself = *this; PexorDebug("Buffer::operator== comparing %d integers:\n",buflen); for(int i=0; iLength()) buflen=Length(); // we do not change our buffer size here! // take minimum of both buffer sizes as copy length and optionally fill up rest with zeros: for(int i=0; i