Ejemplo n.º 1
0
void
tr_bandwidthUsed( tr_bandwidth  * b,
                  tr_direction    dir,
                  size_t          byteCount,
                  tr_bool         isPieceData,
                  uint64_t        now )
{
    struct tr_band * band;

    assert( tr_isBandwidth( b ) );
    assert( tr_isDirection( dir ) );

    band = &b->band[dir];

    if( band->isLimited && isPieceData )
        band->bytesLeft -= MIN( band->bytesLeft, byteCount );

#ifdef DEBUG_DIRECTION
if( ( dir == DEBUG_DIRECTION ) && ( band->isLimited ) )
fprintf( stderr, "%p consumed %5zu bytes of %5s data... was %6zu, now %6zu left\n",
         b, byteCount, (isPieceData?"piece":"raw"), oldBytesLeft, band->bytesLeft );
#endif

    bytesUsed( now, &band->raw, byteCount );

    if( isPieceData )
        bytesUsed( now, &band->piece, byteCount );

    if( b->parent != NULL )
        tr_bandwidthUsed( b->parent, dir, byteCount, isPieceData, now );
}
 virtual ref<ArrayAbstract> clone() const
 {
   ref<Array> arr = new Array;
   if (size())
   {
     arr->resize(size());
     memcpy(arr->ptr(), ptr(), bytesUsed());
   }
   return arr;
 }
Ejemplo n.º 3
0
    uint64_t Namespace::bytesUsedDeep() const
    {
        uint64_t size = bytesUsed();

        Atom prefix = getPrefix();
        if (AvmCore::isString(prefix))
            size += AvmCore::atomToString(prefix)->bytesUsed();

        size += getURI()->bytesUsed();

        return size;
    }
Ejemplo n.º 4
0
uint8_t* Buffer::getData(uint32_t& size)
{
    uint8_t* pPtr = m_pReadPtr;
    size = std::min(bytesUsed(), size);
    if (m_pReadPtr + size >= m_pEnd)
    {
        size = static_cast<uint32_t>(m_pEnd - m_pReadPtr);
        m_pReadPtr = m_pAudioBuffer;
    }
    else
    {
        m_pReadPtr += size;
    }

    m_Fill -= size;
    return pPtr;
}
 //! Copies only the local data and not the VBO related fields
 void operator=(const ArrayAbstract& other) 
 {
   gpuBuffer()->resize( other.gpuBuffer()->bytesUsed() );
   memcpy( ptr(), other.ptr(), bytesUsed() );
   setVBODirty(true);
 }
 size_t size() const { return bytesUsed() / bytesPerVector(); }
Ejemplo n.º 7
0
int MemoryWatcher::bytesFree() const {

    return User::Heap().MaxLength() - bytesUsed();
}
Ejemplo n.º 8
0
int MemoryWatcher::usage() const {

    return 100 * bytesUsed() / User::Heap().MaxLength();
}