. To avoid leaking memory, stick to using Janet's data structures, which
are garbage collected, or
use Janet's scratch memory API to allocate memory. The scratch memory API exposes functions similar to <code class="mendoza-code">malloc</code> and
<code class="mendoza-code">free</code>, but the memory will be automatically freed on the next garbage collection cycle if <code class="mendoza-code">janet_sfree</code> is not called.
</p>
<pre class="mendoza-codeblock"><code data-language="c"><span class="mdzsyn-t