// // libtgvoip is free and unencumbered public domain software. // For more information, see http://unlicense.org or the UNLICENSE file // you should have received with this source code distribution. // #include "BufferPool.h" #include "logging.h" #include #include using namespace tgvoip; BufferPool::BufferPool(unsigned int size, unsigned int count){ assert(count<=64); buffers[0]=(unsigned char*) malloc(size*count); bufferCount=count; unsigned int i; for(i=1;isize=size; } BufferPool::~BufferPool(){ free(buffers[0]); } unsigned char* BufferPool::Get(){ MutexGuard m(mutex); int i; for(i=0;i> i) & 1)){ usedBuffers|=(1LL << i); return buffers[i]; } } return NULL; } void BufferPool::Reuse(unsigned char* buffer){ MutexGuard m(mutex); int i; for(i=0;i