Esempio n. 1
0
 bool scrollEnd(size_t nr)
 {
     if (nr > freeSize())
         return false;
     data_.end += nr;
     return true;
 }
Esempio n. 2
0
 bool write(const Data &data)
 {
     if (freeSize() < data.size())
         return false;
     for (auto t: data)
         push_back(t);
     return true;
 }
Esempio n. 3
0
void* reallocSize(void* old_addr, size_t old_size, size_t new_size)
{
  if (old_addr && new_size)
  {
   void* new_addr;
    omTypeReallocAlignedSize(old_addr, old_size, void*, new_addr, new_size);
    OM_MARK_AS_STATIC(new_addr);
    return new_addr;
  }
  else
  {
    freeSize(old_addr, old_size);
    return malloc(new_size);
  }
}
Esempio n. 4
0
/**
 * Merge a sublist puddle into the receiver.
 * Copy as many entries from the sourcePuddle into the receiver as can fit.  There is the possibility
 * that the sourcePuddle will not have all of its elements copied.  The routine guarantees that both
 * puddles will be in the correct state (with internal list pointers correctly adjusted) upon return.
 */
void
MM_SublistPuddle::merge(MM_SublistPuddle *sourcePuddle)
{
	uintptr_t availableSize, copySize;

	availableSize = freeSize();
	copySize = sourcePuddle->consumedSize();

	/* Determine the actual copy size */
	if(availableSize < copySize) {
		copySize = availableSize;
	}

	/* Copy the data from the tail of the source puddle */
	memcpy(_listCurrent, ((uint8_t *)sourcePuddle->_listCurrent) - copySize, copySize);
	/* And clear the data from the source puddle (fragments require preinitialized slots) */
	memset(((uint8_t *)sourcePuddle->_listCurrent) - copySize, 0, copySize);

	/* Adjust the receiver and source puddle list pointers */
	_listCurrent = (uintptr_t *) (((uint8_t *)_listCurrent) + copySize);
	sourcePuddle->_listCurrent = (uintptr_t *) (((uint8_t *)sourcePuddle->_listCurrent) - copySize);
}
Esempio n. 5
0
 bool full() const {return freeSize() == 0;}