.\" Copyright (c) 2012 by Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH MALLOC_GET_STATE 3 2017\-09\-15 GNU "Linux Programmer's Manual" .SH 名前 malloc_get_state, malloc_set_state \- malloc 実装の状態を保存/復元する .SH 書式 .nf \fB#include \fP .PP \fBvoid *malloc_get_state(void);\fP .PP \fBint malloc_set_state(void *\fP\fIstate\fP\fB);\fP .fi .SH 説明 \fI注意\fP: これらの関数は glibc バージョン 2.25 で削除された。 .PP \fBmalloc_get_state\fP() 関数は \fBmalloc\fP(3) 内部のすべての管理用変数を記録する (ただし、 ヒープの実際の内容と \fBmalloc_hook\fP(3) 関数ポインターの状態は記録されない)。 状態は \fBmalloc\fP(3) で動的に確保されたシステム依存の opaque な (内部構造は分からない) データ構造体に記録され、 関数の結果としてそのデータ構造体へのポインターが返される (このメモリーは呼び出し元が責任をもって \fBfree\fP(3) する必要がある)。 .PP \fBmalloc_set_state\fP() 関数は、 \fBmalloc\fP(3) 内部のすべての管理用変数を \fIstate\fP が指す opaque なデータ構造体から復元する。 .SH 返り値 成功すると、 \fBmalloc_get_state\fP() は新しく割り当てられたデータ構造体へのポインターを返す。 エラーの場合 (例えば、データ構造体に必要なメモリーが割り当てられなかったなど)、 \fBmalloc_get_state\fP() は NULL を返す。 .PP .\" if(ms->magic != MALLOC_STATE_MAGIC) return -1; .\" /* Must fail if the major version is too high. */ .\" if((ms->version & ~0xffl) > (MALLOC_STATE_VERSION & ~0xffl)) return -2; 成功すると、 \fBmalloc_set_state\fP() は 0 を返す。 実装が \fIstate\fP が正しく作成されたデータ構造体を指していないと検出した場合、 \fBmalloc_set_state\fP() は \-1 を返す。 \fIstate\fP が参照するデータ構造体のバージョンがこの実装が認識するバージョンよりも新しいと実装が検出した場合、 \fBmalloc_set_state\fP() は \-2 を返す。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lbw19 lb lb l l l. インターフェース 属性 値 T{ \fBmalloc_get_state\fP(), \fBmalloc_set_state\fP() T} Thread safety MT\-Safe .TE .sp 1 .SH 準拠 これらの関数は GNU による拡張である。 .SH 注意 これらの関数が役に立つのは、 この \fBmalloc\fP(3) の実装が共有ライブラリの一部として使用され、 ヒープの内容が何か他の方法で保存/復元される場合である。 この手法は GNU Emacs が「ダンプ」関数 ("dumping" function) を実装するのに使用されている。 .PP .\" i.e., calls __malloc_check_init() .\" i.e., malloc checking is not already in use .\" and the caller requested malloc checking これらの関数がフック関数ポインターの保存と復元を行うことはない。 ただし、 2 つ例外がある。 \fBmalloc_get_state\fP() が呼び出された際に malloc チェック (\fBmallopt\fP(3) 参照) が使用中の場合、 \fBmalloc_set_state\fP() は可能なら malloc チェックフックをリセットする。 また、 保存された状態の malloc チェックが使用中でないが、 呼び出し元が malloc チェックを要求していた場合、 フックは 0 にリセットされる。 .SH 関連項目 \fBmalloc\fP(3), \fBmallopt\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。