このページでは

C

Qul::Platform::StackAllocator Class

class Qul::Platform::StackAllocator

キャッシュのために一時的に余分なメモリを必要とする関数のためのシンプルなメモリアロケータを提供します。詳細...

Header: #include <platform/alloc.h>
Since: Qt Quick Ultralite (Platform) 1.5

パブリック型

(since Qt Quick Ultralite (Platform) 1.5) class Allocation

静的パブリックメンバ

int32_t available()

詳細な説明

StackAllocator は、要求されたメモリよりも少ないメモリを与える可能性があり、関数はそれに潔く対処することになっている。

プラットフォーム・ライブラリは、静的メンバ変数をStackAllocator のために予約されたバッファに初期化する必要があります:

  • m_buffer をバッファの先頭に初期化する必要があります。
  • m_top を現在の先頭アドレスに初期化する必要があります。この変数はm_bufferに初期化されなければならない。
  • m_size バッファ・サイズ(バイト単位)。

StackAllocator の典型的な初期化:

#include <platform/alloc.h>

static char scratch_buffer[16 * 1024];
char *StackAllocator::m_buffer = scratch_buffer;
char *StackAllocator::m_top = StackAllocator::m_buffer;
int32_t StackAllocator::m_size = sizeof(scratch_buffer);

StackAllocatorの典型的な使用例:

#include <platform/alloc.h>

Qul::Platform::StackAllocator::Allocation alloc(requestedSize);
if (requestedSize == alloc.size()) {
    doStuff(alloc.data());
} else {
    error();
}

alloc がスコープ外に出ると、デストラクタによってメモリが解放される。

Qul::Platform::StackAllocator::Allocationも参照のこと

メンバ関数ドキュメント

[static] int32_t StackAllocator::available()

割り当て可能なバイト数を返す。

StackAllocator のメンバ変数が初期化されていない場合、この関数はゼロを返します。

特定の Qt ライセンスの下で利用可能です。
詳細はこちら。