Compare commits
No commits in common. "b06efe88a289bd008b1ab63fa79163d8a6eefb5b" and "71964e8aead32d9ef98c529a63fe90e5e2d7a5af" have entirely different histories.
b06efe88a2
...
71964e8aea
2 changed files with 16 additions and 35 deletions
42
STYLEGUIDE
42
STYLEGUIDE
|
|
@ -130,23 +130,21 @@ When authoring a new module, use this as a base plate:
|
|||
}
|
||||
|
||||
|
||||
Memory Management
|
||||
-----------------
|
||||
Bindings
|
||||
--------
|
||||
|
||||
If a custom type needs memory to function, it should
|
||||
always assume the memory it requested came from an arena
|
||||
allocator. This means it is the responsibility of the
|
||||
arena to free the memory, not the custom data type.
|
||||
Binding modules should default to static linking and take
|
||||
an optional '#module_parameter' to link dynamically.
|
||||
Libraries should be pinned to a specific version, and all
|
||||
binaries (.dll, .dylib, etc.) *must* be checked into
|
||||
source control. If possible, use the release build of the
|
||||
library that includes debug information.
|
||||
|
||||
In other words:
|
||||
Bindings should stay as close as possible to the original
|
||||
library. To jai-ify the bindings, create a submodule
|
||||
called 'wrapper' that import and wraps the api.
|
||||
|
||||
Do *not* add procedures that 'free' or 'delete' the memory
|
||||
allocated by the data type.
|
||||
|
||||
Instead, add procedures that 'reset' the data type,
|
||||
allowing the already allocated memory to be reused. For
|
||||
examples, see the 'reset' procedures in 'jc/kv'
|
||||
or 'jc/array'.
|
||||
See: 'thirdparty/raylib' for example bindings.
|
||||
|
||||
|
||||
OS-Specific Code
|
||||
|
|
@ -179,19 +177,3 @@ When writing code for a specific architecture, use
|
|||
the 'jc/arch' module. NEVER create a new file unless
|
||||
absolutely needed.
|
||||
|
||||
|
||||
Bindings
|
||||
--------
|
||||
|
||||
Binding modules should default to static linking and take
|
||||
an optional '#module_parameter' to link dynamically.
|
||||
Libraries should be pinned to a specific version, and all
|
||||
binaries (.dll, .dylib, etc.) *must* be checked into
|
||||
source control. If possible, use the release build of the
|
||||
library that includes debug information.
|
||||
|
||||
Bindings should stay as close as possible to the original
|
||||
library. To jai-ify the bindings, create a submodule
|
||||
called 'wrapper' that import and wraps the api.
|
||||
|
||||
See: 'thirdparty/raylib' for example bindings.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
// @todo(judah): replace array_add
|
||||
|
||||
init :: inline (arr: *[..]$T, allocator: Allocator) {
|
||||
arr.allocator = allocator;
|
||||
}
|
||||
|
||||
append :: inline (arr: *[..]$T, value: T) -> *T {
|
||||
ptr := basic.array_add(arr,, allocator = arr.allocator);
|
||||
ptr.* = value;
|
||||
|
|
@ -25,8 +21,11 @@ resize :: inline (arr: *[..]$T, new_size: int) {
|
|||
basic.array_reserve(arr, new_size,, allocator = arr.allocator);
|
||||
}
|
||||
|
||||
reset :: inline (arr: *[..]$T) {
|
||||
reset :: inline (arr: *[..]$T, $keep_memory := true) {
|
||||
arr.count = 0;
|
||||
#if !keep_memory {
|
||||
mem.release_memory(arr.data,, allocator = arr.allocator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue