mirror of
https://github.com/MachineCognitis/Math.Gmp.Native.git
synced 2024-09-07 09:48:21 +02:00
50 lines
96 KiB
HTML
50 lines
96 KiB
HTML
|
<html><head><meta http-equiv="X-UA-Compatible" content="IE=edge" /><link rel="shortcut icon" href="../icons/favicon.ico" /><link rel="stylesheet" type="text/css" href="../styles/branding.css" /><link rel="stylesheet" type="text/css" href="../styles/branding-en-US.css" /><script type="text/javascript" src="../scripts/branding.js"> </script><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>gmp_lib.mp_get_memory_functions Method </title><meta name="Language" content="en-us" /><meta name="System.Keywords" content="mp_get_memory_functions method" /><meta name="System.Keywords" content="gmp_lib.mp_get_memory_functions method" /><meta name="Microsoft.Help.F1" content="Math.Gmp.Native.gmp_lib.mp_get_memory_functions" /><meta name="Microsoft.Help.Id" content="M:Math.Gmp.Native.gmp_lib.mp_get_memory_functions(Math.Gmp.Native.allocate_function@,Math.Gmp.Native.reallocate_function@,Math.Gmp.Native.free_function@)" /><meta name="Description" content="Get the current allocation functions, storing function pointers to the locations given by the arguments." /><meta name="Microsoft.Help.ContentType" content="Reference" /><meta name="BrandingAware" content="true" /><meta name="container" content="Math.Gmp.Native" /><meta name="file" content="9a229bed-b8b6-e0ad-f153-689455252ec4" /><meta name="guid" content="9a229bed-b8b6-e0ad-f153-689455252ec4" /><link type="text/css" rel="stylesheet" href="../styles/highlight.css" /><script type="text/javascript" src="../scripts/highlight.js"> </script><link rel="stylesheet" type="text/css" href="../styles/branding-Website.css" /><script type="text/javascript" src="../scripts/jquery-1.11.0.min.js"></script><script type="text/javascript" src="../scripts/branding-Website.js"></script><script type="text/javascript" src="../scripts/clipboard.min.js"></script></head><body onload="OnLoad('cs')"><input type="hidden" id="userDataCache" class="userDataStyle" /><div class="pageHeader" id="PageHeader">GMP Native Interface for .NET<form id="SearchForm" method="get" action="#" onsubmit="javascript:TransferToSearchPage(); return false;"><input id="SearchTextBox" type="text" maxlength="200" /><button id="SearchButton" type="submit"></button></form></div><div class="pageBody"><div class="leftNav" id="leftNav"><div id="tocNav"><div class="toclevel0" data-toclevel="0"><a class="tocCollapsed" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="846f5c8a-6cba-433e-9f18-cde2ff5695cd.htm" title="GMP Native Interface for .NET" tocid="roottoc">GMP Native Interface for .NET</a></div><div class="toclevel0" data-toclevel="0"><a class="tocCollapsed" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="d9c51b9f-0c54-770b-28ea-6eebd8fef368.htm" title="Math.Gmp.Native" tocid="d9c51b9f-0c54-770b-28ea-6eebd8fef368">Math.Gmp.Native</a></div><div class="toclevel0" data-toclevel="0"><a class="tocCollapsed" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm" title="gmp_lib Class" tocid="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f">gmp_lib Class</a></div><div class="toclevel1" data-toclevel="1" data-childrenloaded="true"><a class="tocExpanded" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="0fa7cbf3-e8f4-6b14-d829-8aa663e77c74.htm" title="gmp_lib Methods" tocid="0fa7cbf3-e8f4-6b14-d829-8aa663e77c74">gmp_lib Methods</a></div><div class="toclevel2" data-toclevel="2"><a data-tochassubtree="false" href="c9cb6a67-59b8-5c03-f31d-f252441c53f6.htm" title="_mpz_realloc Method " tocid="c9cb6a67-59b8-5c03-f31d-f252441c53f6">_mpz_realloc Method </a></div><div class="toclevel2" data-toclevel="2"><a data-tochassubtree="false" href="2c68671c-cd5c-e2ec-52a2-65b0ca31c3d1.htm" title="allocate Method " tocid="2c68671c-cd5c-e2ec-52a2-65b0ca31c3d1">allocate Method </a></div><div class="toclevel2" data-toclevel="2"><a class="tocCollapsed" onclick="javascript: Toggle(this);" href="#!" /><a data-tochassubtree="true" href="92160da3-b1af-e005-cb05-e3fb4dd524d8.htm" title="free Me
|
|||
|
Get the current allocation functions, storing function pointers to the locations given by the arguments.
|
|||
|
</div><p> </p>
|
|||
|
<strong>Namespace:</strong>
|
|||
|
<a href="d9c51b9f-0c54-770b-28ea-6eebd8fef368.htm">Math.Gmp.Native</a><br />
|
|||
|
<strong>Assembly:</strong>
|
|||
|
Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)<div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('ID1RB')" onkeypress="SectionExpandCollapse_CheckKey('ID1RB', event)" tabindex="0"><img id="ID1RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Syntax</span></div><div id="ID1RBSection" class="collapsibleSection"><div class="codeSnippetContainer"><div class="codeSnippetContainerTabs"><div id="ID0EDCA_tab1" class="codeSnippetContainerTab"><a href="#" onclick="javascript:ChangeTab('ID0EDCA','cs','1','4');return false;">C#</a></div><div id="ID0EDCA_tab2" class="codeSnippetContainerTab"><a href="#" onclick="javascript:ChangeTab('ID0EDCA','vb','2','4');return false;">VB</a></div><div id="ID0EDCA_tab3" class="codeSnippetContainerTab"><a href="#" onclick="javascript:ChangeTab('ID0EDCA','cpp','3','4');return false;">C++</a></div><div id="ID0EDCA_tab4" class="codeSnippetContainerTab"><a href="#" onclick="javascript:ChangeTab('ID0EDCA','fs','4','4');return false;">F#</a></div></div><div class="codeSnippetContainerCodeContainer"><div class="codeSnippetToolBar"><div class="codeSnippetToolBarText"><a id="ID0EDCA_copyCode" href="#" class="copyCodeSnippet" onclick="javascript:CopyToClipboard('ID0EDCA');return false;" title="Copy">Copy</a></div></div><div id="ID0EDCA_code_Div1" class="codeSnippetContainerCode" style="display: block"><pre xml:space="preserve"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">mp_get_memory_functions</span>(
|
|||
|
<span class="keyword">ref</span> <span class="identifier">allocate_function</span> <span class="parameter">alloc_func_ptr</span>,
|
|||
|
<span class="keyword">ref</span> <span class="identifier">reallocate_function</span> <span class="parameter">realloc_func_ptr</span>,
|
|||
|
<span class="keyword">ref</span> <span class="identifier">free_function</span> <span class="parameter">free_func_ptr</span>
|
|||
|
)</pre></div><div id="ID0EDCA_code_Div2" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve"><span class="keyword">Public</span> <span class="keyword">Shared</span> <span class="keyword">Sub</span> <span class="identifier">mp_get_memory_functions</span> (
|
|||
|
<span class="keyword">ByRef</span> <span class="parameter">alloc_func_ptr</span> <span class="keyword">As</span> <span class="identifier">allocate_function</span>,
|
|||
|
<span class="keyword">ByRef</span> <span class="parameter">realloc_func_ptr</span> <span class="keyword">As</span> <span class="identifier">reallocate_function</span>,
|
|||
|
<span class="keyword">ByRef</span> <span class="parameter">free_func_ptr</span> <span class="keyword">As</span> <span class="identifier">free_function</span>
|
|||
|
)</pre></div><div id="ID0EDCA_code_Div3" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve"><span class="keyword">public</span>:
|
|||
|
<span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">mp_get_memory_functions</span>(
|
|||
|
<span class="identifier">allocate_function</span>^% <span class="parameter">alloc_func_ptr</span>,
|
|||
|
<span class="identifier">reallocate_function</span>^% <span class="parameter">realloc_func_ptr</span>,
|
|||
|
<span class="identifier">free_function</span>^% <span class="parameter">free_func_ptr</span>
|
|||
|
)</pre></div><div id="ID0EDCA_code_Div4" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve"><span class="keyword">static</span> <span class="keyword">member</span> <span class="identifier">mp_get_memory_functions</span> :
|
|||
|
<span class="parameter">alloc_func_ptr</span> : <span class="identifier">allocate_function</span> <span class="keyword">byref</span> *
|
|||
|
<span class="parameter">realloc_func_ptr</span> : <span class="identifier">reallocate_function</span> <span class="keyword">byref</span> *
|
|||
|
<span class="parameter">free_func_ptr</span> : <span class="identifier">free_function</span> <span class="keyword">byref</span> <span class="keyword">-></span> <span class="keyword">unit</span>
|
|||
|
</pre></div></div></div><script type="text/javascript">AddLanguageTabSet("ID0EDCA");</script><h4 class="subHeading">Parameters</h4><dl><dt><span class="parameter">alloc_func_ptr</span></dt><dd>Type: <a href="dfe3609d-cc50-e357-4254-e3a8e2847f07.htm">Math.Gmp.Native<span id="LSTC7C1E1C0_1"></span><script type="text/javascript">AddLanguageSpecificTextSet("LSTC7C1E1C0_1?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>allocate_function</a><span id="LSTC7C1E1C0_2"></span><script type="text/javascript">AddLanguageSpecificTextSet("LSTC7C1E1C0_2?cpp=%");</script><br />The memory allocation function.</dd><dt><span class="parameter">realloc_func_ptr</span></dt><dd>Type: <a href="aa9d21b4-a929-d550-5a65-f9cbcfa7f638.htm">Math.Gmp.Native<span id="LSTC7C1E1C0_3"></span><script type="text/javascript">AddLanguageSpecificTextSet("LSTC7C1E1C0_3?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>reallocate_function</a><span id="LSTC7C1E1C0_4"></span><script type="text/javascript">AddLanguageSpecificTextSet("LSTC7C1E1C0_4?cpp=%");</script><br />The memory reallocation function.</dd><dt><span class="parameter">free_func_ptr</span></dt><dd>Type: <a href="2c9876e2-a0f5-14c6-5069-1a9d50b89185.htm">Math.Gmp.Native<span id="LSTC7C1E1C0_5"></span><script type="text/javascript">AddLanguageSpecificTextSet("LSTC7C1E1C0_5?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>free_function</a><span id="LSTC7C1E1C0_6"></span><script type="text/javascript">AddLanguageSpecificTextSet("LSTC7C1E1C0_6?cpp=%");</script><br />The memory de-allocation function.</dd></dl></div><div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('ID2RB')" onkeypress="SectionExpandCollapse_CheckKey('ID2RB', event)" tabindex="0"><img id="ID2RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Examples</span></div><div id="ID2RBSection" class="collapsibleSection"><div class="codeSnippetContainer"><div class="codeSnippetContainerTabs"><div id="ID0EDAABA_tab1" class="codeSnippetContainerTab"><a href="#" onclick="javascript:ChangeTab('ID0EDAABA','cs','1','4');return false;">C#</a></div><div id="ID0EDAABA_tab2" class="codeSnippetContainerTab"><a href="#" onclick="javascript:ChangeTab('ID0EDAABA','vb','2','4');return false;">VB</a></div><div id="ID0EDAABA_tab3" class="codeSnippetContainerTabPhantom"><a href="#" onclick="javascript:ChangeTab('ID0EDAABA','cpp','3','4');return false;">C++</a></div><div id="ID0EDAABA_tab4" class="codeSnippetContainerTabPhantom"><a href="#" onclick="javascript:ChangeTab('ID0EDAABA','fs','4','4');return false;">F#</a></div></div><div class="codeSnippetContainerCodeContainer"><div class="codeSnippetToolBar"><div class="codeSnippetToolBarText"><a id="ID0EDAABA_copyCode" href="#" class="copyCodeSnippet" onclick="javascript:CopyToClipboard('ID0EDAABA');return false;" title="Copy">Copy</a></div></div><div id="ID0EDAABA_code_Div1" class="codeSnippetContainerCode" style="display: block"><pre xml:space="preserve">allocate_function allocate;
|
|||
|
reallocate_function reallocate;
|
|||
|
free_function free;
|
|||
|
|
|||
|
<span class="highlight-comment">// Retrieve the GMP memory allocation functions.</span>
|
|||
|
allocate = <span class="highlight-keyword">null</span>;
|
|||
|
reallocate = <span class="highlight-keyword">null</span>;
|
|||
|
free = <span class="highlight-keyword">null</span>;
|
|||
|
gmp_lib.mp_get_memory_functions(<span class="highlight-keyword">ref</span> allocate, <span class="highlight-keyword">ref</span> reallocate, <span class="highlight-keyword">ref</span> free);
|
|||
|
Assert.IsTrue(allocate != <span class="highlight-keyword">null</span> && reallocate != <span class="highlight-keyword">null</span> && free != <span class="highlight-keyword">null</span>);
|
|||
|
|
|||
|
<span class="highlight-comment">// Allocate and free memory.</span>
|
|||
|
void_ptr p = allocate(<span class="highlight-number">100</span>);
|
|||
|
free(p, <span class="highlight-number">100</span>);</pre></div><div id="ID0EDAABA_code_Div2" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve"><span class="highlight-keyword">Dim</span> allocate <span class="highlight-keyword">As</span> allocate_function
|
|||
|
<span class="highlight-keyword">Dim</span> reallocate <span class="highlight-keyword">As</span> reallocate_function
|
|||
|
<span class="highlight-keyword">Dim</span> free <span class="highlight-keyword">As</span> free_function
|
|||
|
|
|||
|
<span class="highlight-comment">' Retrieve the GMP memory allocation functions.</span>
|
|||
|
allocate = <span class="highlight-keyword">Nothing</span>
|
|||
|
reallocate = <span class="highlight-keyword">Nothing</span>
|
|||
|
free = <span class="highlight-keyword">Nothing</span>
|
|||
|
gmp_lib.mp_get_memory_functions(allocate, reallocate, free)
|
|||
|
Assert.IsTrue(allocate <span class="highlight-keyword">IsNot</span> <span class="highlight-keyword">Nothing</span> <span class="highlight-keyword">AndAlso</span> reallocate <span class="highlight-keyword">IsNot</span> <span class="highlight-keyword">Nothing</span> <span class="highlight-keyword">AndAlso</span> free <span class="highlight-keyword">IsNot</span> <span class="highlight-keyword">Nothing</span>)
|
|||
|
|
|||
|
<span class="highlight-comment">' Allocate and free memory.</span>
|
|||
|
<span class="highlight-keyword">Dim</span> p <span class="highlight-keyword">As</span> void_ptr = allocate(<span class="highlight-number">100</span>)
|
|||
|
free(p, <span class="highlight-number">100</span>)</pre></div><div id="ID0EDAABA_code_Div3" class="codeSnippetContainerCode" style="display: none"><p>No code example is currently available or this language may not be supported.</p></div><div id="ID0EDAABA_code_Div4" class="codeSnippetContainerCode" style="display: none"><p>No code example is currently available or this language may not be supported.</p></div></div></div><script type="text/javascript">AddLanguageTabSet("ID0EDAABA");</script></div><div class="collapsibleAreaRegion" id="seeAlsoSection"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('ID3RB')" onkeypress="SectionExpandCollapse_CheckKey('ID3RB', event)" tabindex="0"><img id="ID3RBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />See Also</span></div><div id="ID3RBSection" class="collapsibleSection"><h4 class="subHeading">Reference</h4><div class="seeAlsoStyle"><a href="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm">gmp_lib Class</a></div><div class="seeAlsoStyle"><a href="d9c51b9f-0c54-770b-28ea-6eebd8fef368.htm">Math.Gmp.Native Namespace</a></div><div class="seeAlsoStyle"><a href="15ac48e3-750c-d154-7d8f-6dcaa137f5db.htm">gmp_lib<span id="LSTC7C1E1C0_7"></span><script type="text/javascript">AddLanguageSpecificTextSet("LSTC7C1E1C0_7?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>mp_set_memory_functions(allocate_function, reallocate_function, free_function)</a></div><div class="seeAlsoStyle"><a href="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm"><a href="https://gmplib.org/manual/Custom-Allocation.html#Custom-Allocation">GNU MP - Custom Allocation</a></a></div></div></div></div><div id="pageFooter" class="pageFooter"> </div></body></html>
|