192 lines
4.7 KiB
HTML
192 lines
4.7 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of MALLOC_GET_STATE</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>MALLOC_GET_STATE</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
malloc_get_state, malloc_set_state - record and restore state of malloc implementation
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/malloc.h">malloc.h</A>></B>
|
|
|
|
<B>void* malloc_get_state(void);</B>
|
|
|
|
<B>int malloc_set_state(void *</B><I>state</I><B>);</B>
|
|
</PRE>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<I>Note</I>:
|
|
|
|
these function are removed in glibc version 2.25.
|
|
<P>
|
|
|
|
The
|
|
<B>malloc_get_state</B>()
|
|
|
|
function records the current state of all
|
|
<B><A HREF="/cgi-bin/man/man2html?3+malloc">malloc</A></B>(3)
|
|
|
|
internal bookkeeping variables
|
|
(but not the actual contents of the heap
|
|
or the state of
|
|
<B><A HREF="/cgi-bin/man/man2html?3+malloc_hook">malloc_hook</A></B>(3)
|
|
|
|
functions pointers).
|
|
The state is recorded in a system-dependent opaque data structure
|
|
dynamically allocated via
|
|
<B><A HREF="/cgi-bin/man/man2html?3+malloc">malloc</A></B>(3),
|
|
|
|
and a pointer to that data structure is returned as the function result.
|
|
(It is the caller's responsibility to
|
|
<B><A HREF="/cgi-bin/man/man2html?3+free">free</A></B>(3)
|
|
|
|
this memory.)
|
|
<P>
|
|
|
|
The
|
|
<B>malloc_set_state</B>()
|
|
|
|
function restores the state of all
|
|
<B><A HREF="/cgi-bin/man/man2html?3+malloc">malloc</A></B>(3)
|
|
|
|
internal bookkeeping variables to the values recorded in
|
|
the opaque data structure pointed to by
|
|
<I>state</I>.
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On success,
|
|
<B>malloc_get_state</B>()
|
|
|
|
returns a pointer to a newly allocated opaque data structure.
|
|
On error (for example, memory could not be allocated for the data structure),
|
|
<B>malloc_get_state</B>()
|
|
|
|
returns NULL.
|
|
<P>
|
|
|
|
On success,
|
|
<B>malloc_set_state</B>()
|
|
|
|
returns 0.
|
|
If the implementation detects that
|
|
<I>state</I>
|
|
|
|
does not point to a correctly formed data structure,
|
|
|
|
<B>malloc_set_state</B>()
|
|
|
|
returns -1.
|
|
If the implementation detects that
|
|
the version of the data structure referred to by
|
|
<I>state</I>
|
|
|
|
is a more recent version than this implementation knows about,
|
|
|
|
|
|
<B>malloc_set_state</B>()
|
|
|
|
returns -2.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ATTRIBUTES</H2>
|
|
|
|
For an explanation of the terms used in this section, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
|
|
|
|
<TABLE BORDER>
|
|
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>malloc_get_state</B>(),
|
|
|
|
<B>malloc_set_state</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Safe<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
These functions are GNU extensions.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
These functions are useful when using this
|
|
<B><A HREF="/cgi-bin/man/man2html?3+malloc">malloc</A></B>(3)
|
|
|
|
implementation as part of a shared library,
|
|
and the heap contents are saved/restored via some other method.
|
|
This technique is used by GNU Emacs to implement its "dumping" function.
|
|
<P>
|
|
|
|
Hook function pointers are never saved or restored by these
|
|
functions, with two exceptions:
|
|
if malloc checking (see
|
|
<B><A HREF="/cgi-bin/man/man2html?3+mallopt">mallopt</A></B>(3))
|
|
|
|
was in use when
|
|
<B>malloc_get_state</B>()
|
|
|
|
was called, then
|
|
<B>malloc_set_state</B>()
|
|
|
|
resets malloc checking hooks
|
|
|
|
if possible;
|
|
|
|
|
|
if malloc checking was not in use in the recorded state,
|
|
but the caller has requested malloc checking,
|
|
then the hooks are reset to 0.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+malloc">malloc</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+mallopt">mallopt</A></B>(3)
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">ATTRIBUTES</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">NOTES</A><DD>
|
|
<DT id="8"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="9"><A HREF="#lbAJ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:47 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|