Packages

builtin
cbindgen
core
core.alloc
core.alloc.arena
core.alloc.atomic
core.alloc.debug
core.alloc.fixed
core.alloc.gc
core.alloc.heap
core.alloc.log
core.alloc.memwatch
core.alloc.pool
core.alloc.ring
core.arg_parse
core.array
core.avl_tree
core.bucket_array
core.conv
core.crypto
core.crypto.keys
core.doc
core.encoding
core.encoding.base64
core.encoding.csv
core.encoding.hex
core.encoding.json
core.encoding.kdl
core.encoding.osad
core.encoding.utf8
core.encoding.xml
core.hash
core.hash.md5
core.hash.sha1
core.hash.sha256
core.heap
core.intrinsics
core.intrinsics.atomics
core.intrinsics.onyx
core.intrinsics.types
core.intrinsics.wasm
core.io
core.io.binary
core.iter
core.js
core.list
core.map
core.math
core.memory
core.misc
core.net
core.os
core.random
core.set
core.slice
core.string
core.sync
core.test
core.thread
core.time
main
runtime
runtime.info
runtime.platform
runtime.vars
simd

package core.alloc.ring

This allocator is great for temporary memory, such as returning a pointer from a function, or storing a formatted string. The memory allocated using this allocator does not need to be freed. The idea is that as you keep allocating you will "wrap around" and start writing over memory that was allocated before. For this reason, it is not safe to use this for any kind of permanent allocation. Also, be wary that you provide this allocator with a buffer big enough to store as much data as you are going to need at any given time.

RingState
RingState :: struct {
    base_ptr: rawptr
    size: u32
    curr: u32
}
make
make :: (buffer: [] u8) -> RingState
make_allocator
make_allocator :: (rs: &RingState) -> Allocator