coffi/docs/coffi.mem.html
2021-10-25 09:59:21 -05:00

37 lines
No EOL
27 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>coffi.mem documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">coffi</span> <span class="project-version">v0.2.277</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>coffi</span></div></div></li><li class="depth-2 branch"><a href="coffi.ffi.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>ffi</span></div></a></li><li class="depth-2 current"><a href="coffi.mem.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>mem</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="coffi.mem.html#var-add-close-action.21"><div class="inner"><span>add-close-action!</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-address-of"><div class="inner"><span>address-of</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-address.3F"><div class="inner"><span>address?</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-alloc"><div class="inner"><span>alloc</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-alloc-instance"><div class="inner"><span>alloc-instance</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-alloc-with"><div class="inner"><span>alloc-with</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-as-segment"><div class="inner"><span>as-segment</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-c-layout"><div class="inner"><span>c-layout</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-clone-segment"><div class="inner"><span>clone-segment</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-connected-scope"><div class="inner"><span>connected-scope</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-copy-segment"><div class="inner"><span>copy-segment</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-defalias"><div class="inner"><span>defalias</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-deserialize"><div class="inner"><span>deserialize</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-deserialize*"><div class="inner"><span>deserialize*</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-deserialize-from"><div class="inner"><span>deserialize-from</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-global-scope"><div class="inner"><span>global-scope</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-java-layout"><div class="inner"><span>java-layout</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-java-prim-layout"><div class="inner"><span>java-prim-layout</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-null.3F"><div class="inner"><span>null?</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-primitive-type"><div class="inner"><span>primitive-type</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-primitive.3F"><div class="inner"><span>primitive?</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-scope-allocator"><div class="inner"><span>scope-allocator</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-segment-scope"><div class="inner"><span>segment-scope</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-seq-of"><div class="inner"><span>seq-of</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-serialize"><div class="inner"><span>serialize</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-serialize*"><div class="inner"><span>serialize*</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-serialize-into"><div class="inner"><span>serialize-into</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-shared-scope"><div class="inner"><span>shared-scope</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-size-of"><div class="inner"><span>size-of</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-slice"><div class="inner"><span>slice</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-slice-global"><div class="inner"><span>slice-global</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-slice-into"><div class="inner"><span>slice-into</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-slice-segments"><div class="inner"><span>slice-segments</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-stack-scope"><div class="inner"><span>stack-scope</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-with-acquired"><div class="inner"><span>with-acquired</span></div></a></li><li class="depth-1"><a href="coffi.mem.html#var-with-offset"><div class="inner"><span>with-offset</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">coffi.mem</h1><div class="doc"><div class="markdown"><p>Functions for managing native allocations, resource scopes, and (de)serialization.</p>
<p>For any new type to be implemented, three multimethods must be overriden, but which three depends on the native representation of the type.</p>
<p>If the native representation of the type is a primitive (whether or not other data beyond the primitive is associated with it, as e.g. a pointer), then <a href="coffi.mem.html#var-primitive-type">primitive-type</a> must be overriden to return which primitive type it is serialized as, then <a href="coffi.mem.html#var-serialize*">serialize*</a> and <a href="coffi.mem.html#var-deserialize*">deserialize*</a> should be overriden.</p>
<p>If the native representation of the type is a composite type, like a union, struct, or array, then <a href="coffi.mem.html#var-c-layout">c-layout</a> must be overriden to return the native layout of the type, and <a href="coffi.mem.html#var-serialize-into">serialize-into</a> and <a href="coffi.mem.html#var-deserialize-from">deserialize-from</a> should be overriden to allow marshaling values of the type into and out of memory segments.</p>
<p>When writing code that manipulates a segment, its best practice to use <a href="coffi.mem.html#var-with-acquired">with-acquired</a> on the <a href="coffi.mem.html#var-segment-scope">segment-scope</a> in order to ensure it wont be released during its manipulation.</p></div></div><div class="public anchor" id="var-add-close-action.21"><h3>add-close-action!</h3><div class="usage"><code>(add-close-action! scope action)</code></div><div class="doc"><div class="markdown"><p>Adds a 0-arity function to be run when the <code>scope</code> closes.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L182">view source</a></div></div><div class="public anchor" id="var-address-of"><h3>address-of</h3><div class="usage"><code>(address-of addressable)</code></div><div class="doc"><div class="markdown"><p>Gets the address of a given segment.</p>
<p>This value can be used as an argument to functions which take a pointer.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L121">view source</a></div></div><div class="public anchor" id="var-address.3F"><h3>address?</h3><div class="usage"><code>(address? addr)</code></div><div class="doc"><div class="markdown"><p>Checks if an object is a memory address.</p>
<p><code>nil</code> is considered an address.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L133">view source</a></div></div><div class="public anchor" id="var-alloc"><h3>alloc</h3><div class="usage"><code>(alloc size)</code><code>(alloc size scope)</code></div><div class="doc"><div class="markdown"><p>Allocates <code>size</code> bytes.</p>
<p>If a <code>scope</code> is provided, the allocation will be reclaimed when it is closed.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L86">view source</a></div></div><div class="public anchor" id="var-alloc-instance"><h3>alloc-instance</h3><div class="usage"><code>(alloc-instance type)</code><code>(alloc-instance type scope)</code></div><div class="doc"><div class="markdown"><p>Allocates a memory segment for the given <code>type</code>.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L352">view source</a></div></div><div class="public anchor" id="var-alloc-with"><h3>alloc-with</h3><div class="usage"><code>(alloc-with allocator size)</code><code>(alloc-with allocator size alignment)</code></div><div class="doc"><div class="markdown"><p>Allocates <code>size</code> bytes using the <code>allocator</code>.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L93">view source</a></div></div><div class="public anchor" id="var-as-segment"><h3>as-segment</h3><div class="usage"><code>(as-segment address size scope)</code><code>(as-segment address size scope cleanup)</code></div><div class="doc"><div class="markdown"><p>Dereferences an <code>address</code> into a memory segment associated with the <code>scope</code>.</p>
<p>If <code>cleanup</code> is provided, it is a 0-arity function run when the scope is closed. This can be used to register a free method for the memory, or do other cleanup in a way that doesnt require modifying the code at the point of freeing, and allows shared or garbage collected resources to be freed correctly.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L169">view source</a></div></div><div class="public anchor" id="var-c-layout"><h3>c-layout</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Gets the layout object for a given <code>type</code>.</p>
<p>If a type is primitive it will return the appropriate primitive layout (see <a href="null">c-prim-layout</a>).</p>
<p>Otherwise, it should return a <a href="null">GroupLayout</a> for the given type.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L277">view source</a></div></div><div class="public anchor" id="var-clone-segment"><h3>clone-segment</h3><div class="usage"><code>(clone-segment segment)</code><code>(clone-segment segment scope)</code></div><div class="doc"><div class="markdown"><p>Clones the content of <code>segment</code> into a new segment of the same size.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L193">view source</a></div></div><div class="public anchor" id="var-connected-scope"><h3>connected-scope</h3><div class="usage"><code>(connected-scope)</code></div><div class="doc"><div class="markdown"><p>Constructs a new scope to reclaim all connected resources at once.</p>
<p>The scope may be shared across threads, and all resources created with it will be cleaned up at the same time, when all references have been collected.</p>
<p>This type of scope cannot be closed, and therefore should not be created in a <a href="null">with-open</a> clause.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L51">view source</a></div></div><div class="public anchor" id="var-copy-segment"><h3>copy-segment</h3><div class="usage"><code>(copy-segment dest src)</code></div><div class="doc"><div class="markdown"><p>Copies the content to <code>dest</code> from <code>src</code></p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L187">view source</a></div></div><div class="public anchor" id="var-defalias"><h3>defalias</h3><h4 class="type">macro</h4><div class="usage"><code>(defalias new-type aliased-type)</code></div><div class="doc"><div class="markdown"><p>Defines a type alias from <code>new-type</code> to <code>aliased-type</code>.</p>
<p>This creates needed serialization and deserialization implementations for the aliased type.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L772">view source</a></div></div><div class="public anchor" id="var-deserialize"><h3>deserialize</h3><div class="usage"><code>(deserialize obj type)</code></div><div class="doc"><div class="markdown"><p>Deserializes an arbitrary type.</p>
<p>For types which have a primitive representation, this deserializes the primitive representation. For types which do not, this deserializes out of a segment.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L629">view source</a></div></div><div class="public anchor" id="var-deserialize*"><h3>deserialize*</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Deserializes a primitive object into a Clojure data structure.</p>
<p>This is intended for use with types that are returned as a primitive but which need additional processing before they can be returned.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L569">view source</a></div></div><div class="public anchor" id="var-deserialize-from"><h3>deserialize-from</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Deserializes the given segment into a Clojure data structure.</p>
<p>For types that serialize to primitives, a default implementation will deserialize the primitive before calling <a href="coffi.mem.html#var-deserialize*">deserialize*</a>.</p>
<p>Implementations of this should be inside a <a href="coffi.mem.html#var-with-acquired">with-acquired</a> block for the the <code>segment</code>s scope if they perform multiple memory operations.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L508">view source</a></div></div><div class="public anchor" id="var-global-scope"><h3>global-scope</h3><div class="usage"><code>(global-scope)</code></div><div class="doc"><div class="markdown"><p>Constructs the global scope, which will never reclaim its resources.</p>
<p>This scope may be shared across threads, but is intended mainly in cases where memory is allocated with <a href="coffi.mem.html#var-alloc">alloc</a> but is either never freed or whose management is relinquished to a native library, such as when returned from a callback.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L62">view source</a></div></div><div class="public anchor" id="var-java-layout"><h3>java-layout</h3><div class="usage"><code>(java-layout type)</code></div><div class="doc"><div class="markdown"><p>Gets the Java class to an argument of this type for a method handle.</p>
<p>If a type serializes to a primitive it returns return a Java primitive type. Otherwise, it returns <a href="null">MemorySegment</a>.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L339">view source</a></div></div><div class="public anchor" id="var-java-prim-layout"><h3>java-prim-layout</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>Map of primitive type names to the Java types for a method handle.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L326">view source</a></div></div><div class="public anchor" id="var-null.3F"><h3>null?</h3><div class="usage"><code>(null? addr)</code></div><div class="doc"><div class="markdown"><p>Checks if a memory address is null.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L128">view source</a></div></div><div class="public anchor" id="var-primitive-type"><h3>primitive-type</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Gets the primitive type that is used to pass as an argument for the <code>type</code>.</p>
<p>This is for objects which are passed to native functions as primitive types, but which need additional logic to be performed during serialization and deserialization.</p>
<p>Implementations of this method should take into account that type arguments may not always be evaluated before passing to this function.</p>
<p>Returns nil for any type which does not have a primitive representation.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L220">view source</a></div></div><div class="public anchor" id="var-primitive.3F"><h3>primitive?</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>A set of all primitive types.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L215">view source</a></div></div><div class="public anchor" id="var-scope-allocator"><h3>scope-allocator</h3><div class="usage"><code>(scope-allocator scope)</code></div><div class="doc"><div class="markdown"><p>Constructs a segment allocator from the given <code>scope</code>.</p>
<p>This is primarily used when working with unwrapped downcall functions. When a downcall function returns a non-primitive type, it must be provided with an allocator.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L72">view source</a></div></div><div class="public anchor" id="var-segment-scope"><h3>segment-scope</h3><div class="usage"><code>(segment-scope segment)</code></div><div class="doc"><div class="markdown"><p>Gets the scope used to construct the <code>segment</code>.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L81">view source</a></div></div><div class="public anchor" id="var-seq-of"><h3>seq-of</h3><div class="usage"><code>(seq-of type segment)</code></div><div class="doc"><div class="markdown"><p>Constructs a lazy sequence of <code>type</code> elements deserialized from <code>segment</code>.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L641">view source</a></div></div><div class="public anchor" id="var-serialize"><h3>serialize</h3><div class="usage"><code>(serialize obj type)</code><code>(serialize obj type scope)</code></div><div class="doc"><div class="markdown"><p>Serializes an arbitrary type.</p>
<p>For types which have a primitive representation, this serializes into that representation. For types which do not, it allocates a new segment and serializes into that.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L492">view source</a></div></div><div class="public anchor" id="var-serialize*"><h3>serialize*</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Constructs a serialized version of the <code>obj</code> and returns it.</p>
<p>Any new allocations made during the serialization should be tied to the given <code>scope</code>, except in extenuating circumstances.</p>
<p>This method should only be implemented for types that serialize to primitives.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L359">view source</a></div></div><div class="public anchor" id="var-serialize-into"><h3>serialize-into</h3><h4 class="type">multimethod</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Writes a serialized version of the <code>obj</code> to the given <code>segment</code>.</p>
<p>Any new allocations made during the serialization should be tied to the given <code>scope</code>, except in extenuating circumstances.</p>
<p>This method should be implemented for any type which does not override <a href="coffi.mem.html#var-c-layout">c-layout</a>.</p>
<p>For any other type, this will serialize it as <a href="coffi.mem.html#var-serialize*">serialize*</a> before writing the result value into the <code>segment</code>.</p>
<p>Implementations of this should be inside a <a href="coffi.mem.html#var-with-acquired">with-acquired</a> block for the <code>scope</code> if they perform multiple memory operations.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L424">view source</a></div></div><div class="public anchor" id="var-shared-scope"><h3>shared-scope</h3><div class="usage"><code>(shared-scope)</code></div><div class="doc"><div class="markdown"><p>Constructs a new shared scope.</p>
<p>This scope can be shared across threads and memory allocated in it will only be cleaned up once every thread accessing the scope closes it.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L43">view source</a></div></div><div class="public anchor" id="var-size-of"><h3>size-of</h3><div class="usage"><code>(size-of type)</code></div><div class="doc"><div class="markdown"><p>The size in bytes of the given <code>type</code>.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L347">view source</a></div></div><div class="public anchor" id="var-slice"><h3>slice</h3><div class="usage"><code>(slice segment offset)</code><code>(slice segment offset size)</code></div><div class="doc"><div class="markdown"><p>Get a slice over the <code>segment</code> with the given <code>offset</code>.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L150">view source</a></div></div><div class="public anchor" id="var-slice-global"><h3>slice-global</h3><div class="usage"><code>(slice-global address size)</code></div><div class="doc"><div class="markdown"><p>Gets a slice of the global address space.</p>
<p>Because this fetches from the global segment, it has no associated scope, and therefore the reference created here cannot prevent the value from being freed. Be careful to ensure that you are not retaining an object incorrectly.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L140">view source</a></div></div><div class="public anchor" id="var-slice-into"><h3>slice-into</h3><div class="usage"><code>(slice-into address segment)</code><code>(slice-into address segment size)</code></div><div class="doc"><div class="markdown"><p>Get a slice into the <code>segment</code> starting at the <code>address</code>.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L157">view source</a></div></div><div class="public anchor" id="var-slice-segments"><h3>slice-segments</h3><div class="usage"><code>(slice-segments segment size)</code></div><div class="doc"><div class="markdown"><p>Constructs a lazy seq of <code>size</code>-length memory segments, sliced from <code>segment</code>.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L201">view source</a></div></div><div class="public anchor" id="var-stack-scope"><h3>stack-scope</h3><div class="usage"><code>(stack-scope)</code></div><div class="doc"><div class="markdown"><p>Constructs a new scope for use only in this thread.</p>
<p>The memory allocated within this scope is cheap to allocate, like a native stack.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L35">view source</a></div></div><div class="public anchor" id="var-with-acquired"><h3>with-acquired</h3><h4 class="type">macro</h4><div class="usage"><code>(with-acquired scopes &amp; body)</code></div><div class="doc"><div class="markdown"><p>Acquires one or more <code>scopes</code> until the <code>body</code> completes.</p>
<p>This is only necessary to do on shared scopes, however if you are operating on an arbitrary passed scope, it is best practice to wrap code that interacts with it wrapped in this.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L100">view source</a></div></div><div class="public anchor" id="var-with-offset"><h3>with-offset</h3><div class="usage"><code>(with-offset address offset)</code></div><div class="doc"><div class="markdown"><p>Get a new address <code>offset</code> from the old <code>address</code>.</p></div></div><div class="src-link"><a href="https://github.com/IGJoshua/coffi/blob/f106a5cb3fac609b1a38509c2aff8142a6b78853/src/clj/coffi/mem.clj#L164">view source</a></div></div></div></body></html>