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
<spanid="cb10-19"><ahref="#cb10-19" aria-hidden="true" tabindex="-1"></a><spanclass="op">}</span></span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
588
588
</div>
589
-
<p>Also, notice that in this example, we use the keyword <code>defer</code> to run a small piece of code at the end of the current scope, which is the expression <code>allocator.free(input)</code>. When you execute this expression, the allocator will free the memory that it allocated for the <code>input</code> object.</p>
589
+
<p>Also, notice that in this example, we use the <code>defer</code> keyword (which I described at <ahref="01-zig-weird.html#sec-defer" class="quarto-xref"><span>Section 1.9.3</span></a>) to run a small piece of code at the end of the current scope, which is the expression <code>allocator.free(input)</code>. When you execute this expression, the allocator will free the memory that it allocated for the <code>input</code> object.</p>
590
590
<p>We have talked about this at <ahref="#sec-heap" class="quarto-xref"><span>Section 2.1.5</span></a>. You <strong>should always</strong> explicitly free any memory that you allocate using an allocator! You do that by using the <code>free()</code> method of the same allocator object you used to allocate this memory. The <code>defer</code> keyword is used in this example only to help us execute this free operation at the end of the current scope.</p>
0 commit comments