#author("2017-05-16T21:40:21+09:00","default:haikikyou","haikikyou")
#author("2017-05-16T22:14:41+09:00","default:haikikyou","haikikyou")
[[PostgreSQL/開発]]

#contents

* 概要 [#v016fcb6]

- メモリ操作のためのAPI
- メモリはchunkと呼ばれる塊単位で扱われ,context(chunkを管理)に紐づくようになっている
- contextは木構造で管理されており,上位のcontextを破棄することで,下位のcontextの領域もまとめて解放することができる

* 定義 [#de809d9f]

** マクロ [#j74669cf]

*** MemoryContextAllocExtendedのフラグ [#n24f4e6e]

|~マクロ名|~説明|h
|MCXT_ALLOC_HUGE||
|MCXT_ALLOC_NO_OOM||
|MCXT_ALLOC_ZERO||
** 列挙型 [#y26f0bb4]

** 構造体 [#r96eb7d4]

*** MemoryContextCallback [#gc5e6723]

|~番号|~データ型|~フィールド|~説明|h
|1|MemoryContextCallbackFunction|func|コールバック関数|
|2|void*|arg|コールバック関数に渡される引数|
|3|struct MemoryContextCallback|next|コールバック関数リストの次ノード。&br;コールバック関数はリスト構造で管理されており複数のコールバック関数を登録できる。|

*** MemoryContext [#o4c8d69a]

MemoryContextDataポインタの別名

#geshi(c){{
typedef struct MemoryContextData *MemoryContext;
}}

&size(12){&color(white,orange){ 参考 };};  [[struct MemoryContextData >https://doxygen.postgresql.org/structMemoryContextData.html]] - on doxygen.postgresql.org
** 関数 [#f482c76f]

*** 関数名 [#g8ba4852]
*** MemoryContextAlloc [#g8ba4852]

#geshi(c){{
// 引数1:
extern ForeignServer *GetForeignServer(Oid serverid);
// 引数2:
extern void *MemoryContextAlloc(MemoryContext context, Size size);
}}

- 説明

*** MemoryContextAllocZero [#g8ba4852]

#geshi(c){{
// 引数1:
// 引数2:
extern void *MemoryContextAllocZero(MemoryContext context, Size size);
}}

*** MemoryContextAllocZeroAligned [#g8ba4852]

#geshi(c){{
// 引数1:
// 引数2:
extern void *MemoryContextAllocZeroAligned(MemoryContext context, Size size);
}}

*** MemoryContextAllocExtended [#g8ba4852]

#geshi(c){{
// 引数1:
// 引数2:
// 引数3:
extern void *MemoryContextAllocExtended(MemoryContext context, Size size, int flags);
}}

*** palloc [#g8ba4852]

#geshi(c){{
// 引数1:
extern void *palloc(Size size);
}}

*** palloc0 [#g8ba4852]

#geshi(c){{
// 引数1:
extern void *palloc0(Size size);
}}

*** palloc_extended [#g8ba4852]

#geshi(c){{
// 引数1:
extern void *palloc_extended(Size size, int flags);
}}

*** repalloc [#g8ba4852]

#geshi(c){{
// 引数1:
// 引数2:
extern void *repalloc(void *pointer, Size size);
}}

*** pfree [#g8ba4852]

#geshi(c){{
// 引数1:
extern void pfree(void *pointer);
}}

*** MemoryContextAllocHuge [#g8ba4852]

#geshi(c){{
// 引数1:
// 引数2:
extern void *MemoryContextAllocHuge(MemoryContext context, Size size);
}}


*** repalloc_huge [#g8ba4852]

#geshi(c){{
// 引数1:
// 引数2:
extern void *repalloc_huge(void *pointer, Size size);
}}

*** MemoryContextSwitchTo [#g8ba4852]

#geshi(c){{
// 引数1:
// 戻り値:
MemoryContext MemoryContextSwitchTo(MemoryContext context)
}}

*** MemoryContextRegisterResetCallback [#g8ba4852]

#geshi(c){{
// 引数1:
// 引数2:
// 戻り値:
extern void MemoryContextRegisterResetCallback(MemoryContext context, MemoryContextCallback *cb);
}}

*** MemoryContextStrdup [#g8ba4852]

#geshi(c){{
// 引数1:
// 引数2:
// 戻り値:
extern char *MemoryContextStrdup(MemoryContext context, const char *string);
}}

*** pstrdup [#g8ba4852]

#geshi(c){{
// 引数1:
// 戻り値:
extern char *pstrdup(const char *string);
}}


*** pnstrdup [#g8ba4852]

#geshi(c){{
// 引数1:
// 引数2:
// 戻り値:
extern char *pnstrdup(const char *in, Size len);
}}

*** psprintf [#g8ba4852]

#geshi(c){{
// 引数1:
// 戻り値:
extern char *psprintf(const char *fmt,...) pg_attribute_printf(1, 2);
}}


*** pvsnprintf [#g8ba4852]

#geshi(c){{
// 引数1:
// 引数2:
// 引数3:
// 戻り値:
extern size_t pvsnprintf(char *buf, size_t len, const char *fmt, va_list args) pg_attribute_printf(3, 0);
}}
* サンプルプログラム [#u70bfc73]

#geshi(c){{
// sample
}}

* 参考・関連 [#h201be4f]



- [[palloc.h>https://doxygen.postgresql.org/palloc_8h.html]] - on doxygen.postgresql.org
- [[memnodes.h>https://doxygen.postgresql.org/memnodes_8h.html]] - on doxygen.postgresql.org
- [[mcxt.c>https://doxygen.postgresql.org/mcxt_8c.html]] - on doxygen.postgresql.org
* コメント [#baa736e7]

#comment


トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
目次
ダブルクリックで閉じるTOP | 閉じる
GO TO TOP