You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 16, 2024. It is now read-only.
<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport" content="width=device-width, initial-scale=1.0"><metaname="generator" content="rustdoc"><metaname="description" content="Allocate memory with the global allocator."><title>alloc in alloc::alloc - Rust</title><linkrel="preload" as="font" type="font/woff2" crossoriginhref="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><linkrel="preload" as="font" type="font/woff2" crossoriginhref="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><linkrel="preload" as="font" type="font/woff2" crossoriginhref="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><linkrel="preload" as="font" type="font/woff2" crossoriginhref="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><linkrel="preload" as="font" type="font/woff2" crossoriginhref="../../static.files/SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2"><linkrel="preload" as="font" type="font/woff2" crossoriginhref="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><linkrel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet" href="../../static.files/rustdoc-fa3bb1812debf86c.css"><metaname="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="alloc" data-themes="" data-resource-suffix="" data-rustdoc-version="1.74.1 (a28077b28 2023-12-04)" data-channel="1.74.1" data-search-js="search-8be46b629f5f14a8.js" data-settings-js="settings-74424d7eec62a23e.js" ><scriptsrc="../../static.files/storage-fec3eaa3851e447d.js"></script><scriptdefersrc="sidebar-items.js"></script><scriptdefersrc="../../static.files/main-c5bd66d33317d69f.js"></script><noscript><linkrel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><linkrel="icon" type="image/svg+xml" href="../../static.files/logo.svg"></head><bodyclass="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="mobile-topbar"><buttonclass="sidebar-menu-toggle">☰</button><aclass="logo-container" href="../../alloc/index.html"><imgclass="rust-logo" src="../../static.files/logo.svg" alt="logo"></a></nav><navclass="sidebar"><aclass="logo-container" href="../../alloc/index.html"><imgclass="rust-logo" src="../../static.files/logo.svg" alt="logo"></a><divclass="sidebar-elems"><h2><ahref="index.html">In alloc::alloc</a></h2></div></nav><main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><inputclass="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><divid="help-button" title="help" tabindex="-1"><ahref="../../help.html">?</a></div><divid="settings-menu" tabindex="-1"><ahref="../../settings.html" title="settings"><imgwidth="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><sectionid="main-content" class="content"><divclass="main-heading"><h1>Function <ahref="../index.html">alloc</a>::<wbr><ahref="index.html">alloc</a>::<wbr><aclass="fn" href="#">alloc</a><buttonid="copy-path" title="Copy item path to clipboard"><imgsrc="../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><spanclass="out-of-band"><spanclass="since" title="Stable since Rust version 1.28.0">1.28.0</span> · <aclass="src" href="../../src/alloc/alloc.rs.html#94-102">source</a> · <buttonid="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><preclass="rust item-decl"><code>pub unsafe fn alloc(layout: <aclass="struct" href="struct.Layout.html" title="struct alloc::alloc::Layout">Layout</a>) -> <aclass="primitive" href="../../core/primitive.pointer.html">*mut </a><aclass="primitive" href="../../core/primitive.u8.html">u8</a></code></pre><detailsclass="toggle top-doc" open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>Allocate memory with the global allocator.</p>
2
+
<p>This function forwards calls to the <ahref="trait.GlobalAlloc.html#tymethod.alloc" title="method alloc::alloc::GlobalAlloc::alloc"><code>GlobalAlloc::alloc</code></a> method
3
+
of the allocator registered with the <code>#[global_allocator]</code> attribute
4
+
if there is one, or the <code>std</code> crate’s default.</p>
5
+
<p>This function is expected to be deprecated in favor of the <code>alloc</code> method
6
+
of the <ahref="struct.Global.html" title="struct alloc::alloc::Global"><code>Global</code></a> type when it and the <ahref="trait.Allocator.html" title="trait alloc::alloc::Allocator"><code>Allocator</code></a> trait become stable.</p>
<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport" content="width=device-width, initial-scale=1.0"><metaname="generator" content="rustdoc"><metaname="description" content="Allocate zero-initialized memory with the global allocator."><title>alloc_zeroed in alloc::alloc - Rust</title><linkrel="preload" as="font" type="font/woff2" crossoriginhref="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><linkrel="preload" as="font" type="font/woff2" crossoriginhref="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><linkrel="preload" as="font" type="font/woff2" crossoriginhref="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><linkrel="preload" as="font" type="font/woff2" crossoriginhref="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><linkrel="preload" as="font" type="font/woff2" crossoriginhref="../../static.files/SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2"><linkrel="preload" as="font" type="font/woff2" crossoriginhref="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><linkrel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet" href="../../static.files/rustdoc-fa3bb1812debf86c.css"><metaname="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="alloc" data-themes="" data-resource-suffix="" data-rustdoc-version="1.74.1 (a28077b28 2023-12-04)" data-channel="1.74.1" data-search-js="search-8be46b629f5f14a8.js" data-settings-js="settings-74424d7eec62a23e.js" ><scriptsrc="../../static.files/storage-fec3eaa3851e447d.js"></script><scriptdefersrc="sidebar-items.js"></script><scriptdefersrc="../../static.files/main-c5bd66d33317d69f.js"></script><noscript><linkrel="stylesheet" href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><linkrel="icon" type="image/svg+xml" href="../../static.files/logo.svg"></head><bodyclass="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="mobile-topbar"><buttonclass="sidebar-menu-toggle">☰</button><aclass="logo-container" href="../../alloc/index.html"><imgclass="rust-logo" src="../../static.files/logo.svg" alt="logo"></a></nav><navclass="sidebar"><aclass="logo-container" href="../../alloc/index.html"><imgclass="rust-logo" src="../../static.files/logo.svg" alt="logo"></a><divclass="sidebar-elems"><h2><ahref="index.html">In alloc::alloc</a></h2></div></nav><main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><inputclass="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><divid="help-button" title="help" tabindex="-1"><ahref="../../help.html">?</a></div><divid="settings-menu" tabindex="-1"><ahref="../../settings.html" title="settings"><imgwidth="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><sectionid="main-content" class="content"><divclass="main-heading"><h1>Function <ahref="../index.html">alloc</a>::<wbr><ahref="index.html">alloc</a>::<wbr><aclass="fn" href="#">alloc_zeroed</a><buttonid="copy-path" title="Copy item path to clipboard"><imgsrc="../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><spanclass="out-of-band"><spanclass="since" title="Stable since Rust version 1.28.0">1.28.0</span> · <aclass="src" href="../../src/alloc/alloc.rs.html#171-173">source</a> · <buttonid="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><preclass="rust item-decl"><code>pub unsafe fn alloc_zeroed(layout: <aclass="struct" href="struct.Layout.html" title="struct alloc::alloc::Layout">Layout</a>) -> <aclass="primitive" href="../../core/primitive.pointer.html">*mut </a><aclass="primitive" href="../../core/primitive.u8.html">u8</a></code></pre><detailsclass="toggle top-doc" open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>Allocate zero-initialized memory with the global allocator.</p>
2
+
<p>This function forwards calls to the <ahref="trait.GlobalAlloc.html#method.alloc_zeroed" title="method alloc::alloc::GlobalAlloc::alloc_zeroed"><code>GlobalAlloc::alloc_zeroed</code></a> method
3
+
of the allocator registered with the <code>#[global_allocator]</code> attribute
4
+
if there is one, or the <code>std</code> crate’s default.</p>
5
+
<p>This function is expected to be deprecated in favor of the <code>alloc_zeroed</code> method
6
+
of the <ahref="struct.Global.html" title="struct alloc::alloc::Global"><code>Global</code></a> type when it and the <ahref="trait.Allocator.html" title="trait alloc::alloc::Allocator"><code>Allocator</code></a> trait become stable.</p>
0 commit comments