예제 #1
0
파일: IOQueue.cpp 프로젝트: Jazeido/ola
/**
 * Remove the first n bytes from the buffer
 */
void IOQueue::Pop(unsigned int n) {
  unsigned int bytes_popped = 0;
  BlockVector::iterator iter = m_blocks.begin();
  while (iter != m_blocks.end() && bytes_popped != n) {
    MemoryBlock *block = *iter;
    bytes_popped += block->PopFront(n - bytes_popped);
    if (block->Empty()) {
      m_pool->Release(block);
      iter = m_blocks.erase(iter);
    } else {
      iter++;
    }
  }
}
예제 #2
0
파일: IOStack.cpp 프로젝트: dandaka/ola
/**
 * Remove bytes from the stack
 */
void IOStack::Pop(unsigned int bytes_to_remove) {
    unsigned int bytes_removed = 0;
    BlockVector::iterator iter = m_blocks.begin();
    while (iter != m_blocks.end() && bytes_removed != bytes_to_remove) {
        MemoryBlock *block = *iter;
        bytes_removed += block->PopFront(bytes_to_remove - bytes_removed);
        if (block->Empty()) {
            m_pool->Release(block);
            iter = m_blocks.erase(iter);
        } else {
            iter++;
        }
    }
}
예제 #3
0
파일: IOQueue.cpp 프로젝트: Jazeido/ola
/**
 * Read up to n bytes into the memory location data and shrink the IOQueue by
 * the amount read.
 */
unsigned int IOQueue::Read(uint8_t *data, unsigned int n) {
  unsigned int bytes_read = 0;
  BlockVector::iterator iter = m_blocks.begin();
  while (iter != m_blocks.end() && bytes_read != n) {
    MemoryBlock *block = *iter;
    unsigned int bytes_copied = block->Copy(data + bytes_read, n - bytes_read);
    block->PopFront(bytes_copied);
    bytes_read += bytes_copied;
    if (block->Empty()) {
      m_pool->Release(block);
      iter = m_blocks.erase(iter);
    } else {
      iter++;
    }
  }
  return bytes_read;
}