<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 05/06/2024 11:11, <a class="moz-txt-link-abbreviated" href="mailto:forax@univ-mlv.fr">forax@univ-mlv.fr</a>
wrote:<br>
</div>
<blockquote type="cite" cite="mid:334543192.41852752.1717582306322.JavaMail.zimbra@univ-eiffel.fr">
<pre>Here is an example
<a class="moz-txt-link-freetext" href="https://urldefense.com/v3/__https://github.com/forax/memory-mapper/blob/master/src/main/java/com/github/forax/memorymapper/MemoryCollections.java*L772__;Iw!!ACWV5N9M2RV99hQ!PUJIR9R4tNJ_QKk01hd0VFW5mMO0KsBeJk0WxuQsq4MzmNZ0c5WvuGhrAHSJQJGDJog9qIZghlkqNDjgBnxZ8JXAYA$" moz-do-not-send="true">https://urldefense.com/v3/__https://github.com/forax/memory-mapper/blob/master/src/main/java/com/github/forax/memorymapper/MemoryCollections.java*L772__;Iw!!ACWV5N9M2RV99hQ!PUJIR9R4tNJ_QKk01hd0VFW5mMO0KsBeJk0WxuQsq4MzmNZ0c5WvuGhrAHSJQJGDJog9qIZghlkqNDjgBnxZ8JXAYA$</a>
I want to have a List of records (or primitive type) implemented as an
array of flatten values.
I need a way to allocate a zeroed MemorySegment, and I need a way to
grow the storage using the Array.copyOf() semantics.
For the history, I've an existing non-public library that uses Unsafe +
ASM for the code generation and i'm trying to replace it with a new
publicly available library that uses the foreign memory API + the method
handle API + Hidden classes.</pre>
</blockquote>
<p>As you are allocating only one segment, the use of
SegmentAllocator seems fine here. But... if you later on need to
grow storage, it's not a one-shot allocation anymore, and I
believe you need an Arena (as you might need to start managing
different segments with same lifetime).<br>
</p>
<p>You can also go a different route, and use calloc/realloc
directly (via Linker), and avoid the allocator parameter (not sure
how your old API dealt with deallocation safely).</p>
<p>Maurizio<br>
</p>
<p><br>
</p>
</body>
</html>