Liking cljdoc? Tell your friends :D

clj-ebpf.internal.memory

Low-level memory management using Panama FFI.

This namespace provides the foundational memory primitives used throughout clj-ebpf. It wraps Java's Foreign Function & Memory API (Panama) to provide a Clojure-friendly interface for:

  • Memory allocation and deallocation
  • Reading and writing primitive types
  • Memory segment manipulation
  • Buffer management for BPF operations

INTERNAL: This namespace is for internal use only. Public APIs should use clj-ebpf.utils for memory operations.

Low-level memory management using Panama FFI.

This namespace provides the foundational memory primitives used throughout
clj-ebpf. It wraps Java's Foreign Function & Memory API (Panama) to provide
a Clojure-friendly interface for:

- Memory allocation and deallocation
- Reading and writing primitive types
- Memory segment manipulation
- Buffer management for BPF operations

INTERNAL: This namespace is for internal use only. Public APIs should use
clj-ebpf.utils for memory operations.
raw docstring

allocateclj

(allocate size)
(allocate size alignment)

Allocate native memory of given size with optional alignment. Returns a MemorySegment.

Allocate native memory of given size with optional alignment.
Returns a MemorySegment.
sourceraw docstring

allocate-arrayclj

(allocate-array element-layout count)

Allocate an array of elements with the given layout.

Allocate an array of elements with the given layout.
sourceraw docstring

allocate-zeroedclj

(allocate-zeroed size)

Allocate zeroed native memory of given size.

Allocate zeroed native memory of given size.
sourceraw docstring

bytes->segmentclj

(bytes->segment bytes)

Write bytes from a byte array to a new memory segment.

Write bytes from a byte array to a new memory segment.
sourceraw docstring

C_BYTEclj

source

C_DOUBLEclj

source

C_FLOATclj

source

C_INTclj

source

C_INT_BEclj

source

C_INT_LEclj

source

C_LONGclj

source

C_LONG_BEclj

source

C_LONG_LEclj

source

C_POINTERclj

source

C_SHORTclj

source

C_SHORT_BEclj

source

C_SHORT_LEclj

source

copy-segmentclj

(copy-segment dst dst-offset src src-offset length)

Copy bytes from src segment to dst segment.

Copy bytes from src segment to dst segment.
sourceraw docstring

create-auto-arenaclj

(create-auto-arena)

Create an auto-managed arena (GC-collected).

Create an auto-managed arena (GC-collected).
sourceraw docstring

create-confined-arenaclj

(create-confined-arena)

Create a confined arena for explicit memory management. Must be closed when done.

Create a confined arena for explicit memory management.
Must be closed when done.
sourceraw docstring

create-shared-arenaclj

(create-shared-arena)

Create a shared arena for multi-threaded access. Must be closed when done.

Create a shared arena for multi-threaded access.
Must be closed when done.
sourceraw docstring

fill-memoryclj

(fill-memory seg size value)

Fill memory segment with a byte value.

Fill memory segment with a byte value.
sourceraw docstring

from-addressclj

(from-address address size)

Create a memory segment from a native address. Warning: This is unsafe and should be used carefully.

Create a memory segment from a native address.
Warning: This is unsafe and should be used carefully.
sourceraw docstring

NULL-SEGMENTclj

source

null-segment?clj

(null-segment? seg)

Check if a memory segment is NULL.

Check if a memory segment is NULL.
sourceraw docstring

read-byteclj

(read-byte seg offset)

Read a byte from memory segment at offset.

Read a byte from memory segment at offset.
sourceraw docstring

read-intclj

(read-int seg offset)

Read an int from memory segment at offset.

Read an int from memory segment at offset.
sourceraw docstring

read-int-beclj

(read-int-be seg offset)

Read a big-endian int from memory segment at offset.

Read a big-endian int from memory segment at offset.
sourceraw docstring

read-int-leclj

(read-int-le seg offset)

Read a little-endian int from memory segment at offset.

Read a little-endian int from memory segment at offset.
sourceraw docstring

read-longclj

(read-long seg offset)

Read a long from memory segment at offset.

Read a long from memory segment at offset.
sourceraw docstring

read-long-beclj

(read-long-be seg offset)

Read a big-endian long from memory segment at offset.

Read a big-endian long from memory segment at offset.
sourceraw docstring

read-long-leclj

(read-long-le seg offset)

Read a little-endian long from memory segment at offset.

Read a little-endian long from memory segment at offset.
sourceraw docstring

read-pointerclj

(read-pointer seg offset)

Read a pointer from memory segment at offset.

Read a pointer from memory segment at offset.
sourceraw docstring

read-shortclj

(read-short seg offset)

Read a short from memory segment at offset.

Read a short from memory segment at offset.
sourceraw docstring

read-short-beclj

(read-short-be seg offset)

Read a big-endian short from memory segment at offset.

Read a big-endian short from memory segment at offset.
sourceraw docstring

read-short-leclj

(read-short-le seg offset)

Read a little-endian short from memory segment at offset.

Read a little-endian short from memory segment at offset.
sourceraw docstring

reinterpretclj

(reinterpret seg new-size)

Reinterpret a memory segment with a new size.

Reinterpret a memory segment with a new size.
sourceraw docstring

segment->bufferclj

(segment->buffer seg)

Create a ByteBuffer view of a memory segment.

Create a ByteBuffer view of a memory segment.
sourceraw docstring

segment->bytesclj

(segment->bytes seg size)

Read bytes from a memory segment into a byte array.

Read bytes from a memory segment into a byte array.
sourceraw docstring

segment->stringclj

(segment->string seg)
(segment->string seg max-len)

Read a null-terminated string from a memory segment.

Read a null-terminated string from a memory segment.
sourceraw docstring

segment-addressclj

(segment-address seg)

Get the native address of a memory segment.

Get the native address of a memory segment.
sourceraw docstring

segment-sizeclj

(segment-size seg)

Get the size of a memory segment.

Get the size of a memory segment.
sourceraw docstring

sliceclj

(slice seg offset size)

Create a slice of a memory segment.

Create a slice of a memory segment.
sourceraw docstring

string->segmentclj

(string->segment s)

Convert a string to a null-terminated memory segment.

Convert a string to a null-terminated memory segment.
sourceraw docstring

with-confined-arenacljmacro

(with-confined-arena & body)

Execute body with a confined arena that is closed after execution.

Execute body with a confined arena that is closed after execution.
sourceraw docstring

with-shared-arenacljmacro

(with-shared-arena & body)

Execute body with a shared arena that is closed after execution.

Execute body with a shared arena that is closed after execution.
sourceraw docstring

wrap-bytesclj

(wrap-bytes bytes)

Wrap a byte array as a memory segment (no copy).

Wrap a byte array as a memory segment (no copy).
sourceraw docstring

write-byteclj

(write-byte seg offset value)

Write a byte to memory segment at offset.

Write a byte to memory segment at offset.
sourceraw docstring

write-intclj

(write-int seg offset value)

Write an int to memory segment at offset.

Write an int to memory segment at offset.
sourceraw docstring

write-int-beclj

(write-int-be seg offset value)

Write a big-endian int to memory segment at offset.

Write a big-endian int to memory segment at offset.
sourceraw docstring

write-int-leclj

(write-int-le seg offset value)

Write a little-endian int to memory segment at offset.

Write a little-endian int to memory segment at offset.
sourceraw docstring

write-longclj

(write-long seg offset value)

Write a long to memory segment at offset.

Write a long to memory segment at offset.
sourceraw docstring

write-long-beclj

(write-long-be seg offset value)

Write a big-endian long to memory segment at offset.

Write a big-endian long to memory segment at offset.
sourceraw docstring

write-long-leclj

(write-long-le seg offset value)

Write a little-endian long to memory segment at offset.

Write a little-endian long to memory segment at offset.
sourceraw docstring

write-pointerclj

(write-pointer seg offset value)

Write a pointer to memory segment at offset.

Write a pointer to memory segment at offset.
sourceraw docstring

write-shortclj

(write-short seg offset value)

Write a short to memory segment at offset.

Write a short to memory segment at offset.
sourceraw docstring

write-short-beclj

(write-short-be seg offset value)

Write a big-endian short to memory segment at offset.

Write a big-endian short to memory segment at offset.
sourceraw docstring

write-short-leclj

(write-short-le seg offset value)

Write a little-endian short to memory segment at offset.

Write a little-endian short to memory segment at offset.
sourceraw docstring

zero-memoryclj

(zero-memory seg size)

Zero out memory segment.

Zero out memory segment.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close