このページを編集する際は、編集に関する方針に従ってください。
概要 †
- 引数 context 配下の関数ポインタ context->methods->alloc で指定されている関数をコールして、戻り値を返す。
引数 †
- MemoryContext context -- 以下のように使用される。
- 構造体Node/postgresql-8.1.4型のポインタにキャストして、typeメンバに相当する値を評価
- 関数ポインタ context->methods->alloc で示される関数を呼び出し
- 上記関数の引数
- Size size -- 関数ポインタ context->methods->alloc で指定されている関数に与える引数。
実装 †
void *
MemoryContextAlloc(MemoryContext context, Size size)
- MemoryContext/postgresql-8.1.4 -- 下記メンバを持つ構造体MemoryContextDataへのポインタ型。
- NodeTag列挙型の変数type
- 下記メンバを持つ構造体型MemoryContextMethodsへのポインタmethods
- void*型の関数ポインタalloc
- void型の関数ポインタfree_p
- void*型の関数ポインタrealloc
- void型の関数ポインタinit
- void型の関数ポインタreset
- void型の関数ポインタdelete
- Size型の関数ポインタget_chunk_space
- bool型の関数ポインタis_empty
- void型の関数ポインタstats
- void型の関数ポインタcheck
- MemoryContextDataへのポインタparent(再帰的使用)
- MemoryContextDataへのポインタfirstchild(再帰的使用)
- MemoryContextDataへのポインタnextchild(再帰的使用)
- char型へのポインタname
{
AssertArg(MemoryContextIsValid(context));
- AssertArg()/postgresql-8.1.4 -- (USE_ASSERT_CHECKINGを指定したバイナリの場合)assert_enabledが0以外、かつ、評価式MemoryContextIsValid(context)の結果が0である時、エラー情報を出力してプログラムを停止する。
if (!AllocSizeIsValid(size))
elog(ERROR, "invalid memory alloc request size %lu",
(unsigned long) size);
return (*context->methods->alloc) (context, size);
- 関数ポインタ context->methods->alloc で指定されている関数をコールして、戻り値を返す。
}
呼出元 †
備考 †
/*
* Fundamental memory-allocation operations (more are in utils/memutils.h)
*/
/*
* MemoryContextAlloc
* Allocate space within the specified context.
*
* This could be turned into a macro, but we'd have to import
* nodes/memnodes.h into postgres.h which seems a bad idea.
*/
履歴 †
コメント †