o
odin.langpkg.dev
packages / library / odin-libgc

odin-libgc

245df0alibrary

Garbage collection for the Odin language

No license · updated 1 year ago

odin-libgc

This is a simple library wrapper for libgc, providing garbage collection to the Odin programming language.

package main

import "gc"
import "core:fmt"

main :: proc() {
    // Initialize the collector and set the main context.
    // All allocations are now handled by the garbage collector.
    context = gc.initialize()
    
    // The GC string functions always uses the atomic allocator.
    join := gc.sprint("Hello", "World")
    fmt.println(join)

    // fmt.a* functions will use standard GC allocator in this case.
    str := fmt.aprint("foo", "bar")
    fmt.println(str)
}