Ported rxi/lite text editor to odin for fun and learning Odin

I clarified in this post what the differences are between the arena types. I’ve had the thought that maybe the .Buffer variant of virtual.Arena is unneeded when we have mem.Arena, and I’ve shared your confusion at one point about this.

This would be a nice addition. I’m unfamiliar with how the pkg website works, but a workaround right now is to keep the search page open and open new tabs from the search links listed.

Only the odin calling convention carries the implicit context pointer with every call, so this is by design. It’s not so much that it becomes nil as much as that it’s not passed to the procedure in the first place. Every Odin odin procedure can be thought of as having an extra pointer to a runtime.Context structure.

The way you handle this for procedures with c and other contextless calling conventions is to provide it either in a global variable or along with a userdata pointer that the procedure can be made aware of.

You can also make a mem.Tracking_Allocator and hook your allocator up to that to keep track of memory leaks, which should pinpoint where they’re coming from (with some exceptions).

You can do x : Type = 1 or x := Type(1). Were you aware of this, or does that not cover your need here? The := contains an implicit declaration of the type which can be made explicit between the colon and equals sign.

As @zen3ger has pointed out, there’s the -vet-shadowing compile-time option, as well as a whole suite of vetting options that you can see with odin build --help. In the same family of options, there is also -strict-style.

The default context allocator, which uses libc malloc on *NIX-likes and HeapAlloc on Windows, should be thread-safe, but refer to your system’s manual if you’re on a *NIX system. I’m unfamiliar with the orca platform, so I can’t speak to that. That’s the one oddball in the base:runtime/heap_allocator_*.odin set of files.

1 Like