Add function for copying the data from one segment to another
This commit is contained in:
parent
364af931c5
commit
7d970a177f
1 changed files with 6 additions and 1 deletions
|
|
@ -153,12 +153,17 @@
|
||||||
[scope action]
|
[scope action]
|
||||||
(.addCloseAction ^ResourceScope scope action))
|
(.addCloseAction ^ResourceScope scope action))
|
||||||
|
|
||||||
|
(defn copy-segment
|
||||||
|
"Copies the content to `dest` from `src`"
|
||||||
|
[dest src]
|
||||||
|
(.copyFrom ^MemorySegment dest ^MemorySegment src))
|
||||||
|
|
||||||
(defn clone-segment
|
(defn clone-segment
|
||||||
"Clones the content of `segment` into a new segment of the same size."
|
"Clones the content of `segment` into a new segment of the same size."
|
||||||
([segment] (clone-segment segment (connected-scope)))
|
([segment] (clone-segment segment (connected-scope)))
|
||||||
([segment scope]
|
([segment scope]
|
||||||
(doto ^MemorySegment (alloc (.byteSize ^MemorySegment segment) scope)
|
(doto ^MemorySegment (alloc (.byteSize ^MemorySegment segment) scope)
|
||||||
(.copyFrom ^MemorySegment segment))))
|
(copy-segment segment))))
|
||||||
|
|
||||||
(defn slice-segments
|
(defn slice-segments
|
||||||
"Constructs a lazy seq of `size`-length memory segments, sliced from `segment`."
|
"Constructs a lazy seq of `size`-length memory segments, sliced from `segment`."
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue