Compare commits
2 commits
657dec6415
...
606bf14ffe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
606bf14ffe | ||
|
|
7ba85cc2ea |
4 changed files with 34 additions and 3 deletions
2
TODO
2
TODO
|
|
@ -36,7 +36,6 @@
|
||||||
031 [x] standardize error handling (maybe odin-style enums?)
|
031 [x] standardize error handling (maybe odin-style enums?)
|
||||||
032 [memory] more allocators!
|
032 [memory] more allocators!
|
||||||
033 [sort] create sort module with quick sort, radix sort support (in place and copy versions)
|
033 [sort] create sort module with quick sort, radix sort support (in place and copy versions)
|
||||||
034 [x] can we add location info to Allocator_Proc?
|
|
||||||
035 [memory] add debug allocator to track allocation locations, double frees, etc. (should wrap another allocator)
|
035 [memory] add debug allocator to track allocation locations, double frees, etc. (should wrap another allocator)
|
||||||
036 [thread] create *simple* threading module
|
036 [thread] create *simple* threading module
|
||||||
037 [thread] add 'Mutex', 'Semaphore', 'Wait_Group' types - blocked by 036
|
037 [thread] add 'Mutex', 'Semaphore', 'Wait_Group' types - blocked by 036
|
||||||
|
|
@ -83,3 +82,4 @@
|
||||||
004 [thirdparty/luajit] create bindings
|
004 [thirdparty/luajit] create bindings
|
||||||
001 [platform] create module for OS/platform-specific things
|
001 [platform] create module for OS/platform-specific things
|
||||||
024 [x] create file to document conventions/style guide
|
024 [x] create file to document conventions/style guide
|
||||||
|
034 [x] can we add location info to Allocator_Proc?
|
||||||
|
|
|
||||||
30
array/dynamic_array.jai
Normal file
30
array/dynamic_array.jai
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// @todo(judah): replace array_add
|
||||||
|
|
||||||
|
append :: inline (arr: *[..]$T, value: T) -> *T {
|
||||||
|
ptr := basic.array_add(arr);
|
||||||
|
ptr.* = value;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
append :: inline (arr: *[..]$T, values: ..T) -> *T {
|
||||||
|
count := arr.count;
|
||||||
|
basic.array_add(arr, ..values);
|
||||||
|
return *arr.data[count];
|
||||||
|
}
|
||||||
|
|
||||||
|
append :: inline (arr: *[..]$T) -> *T {
|
||||||
|
return basic.array_add(arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
reset :: inline (arr: *[..]$T, $keep_memory := true) {
|
||||||
|
arr.count = 0;
|
||||||
|
#if !keep_memory {
|
||||||
|
mem.release_memory(arr.data,, allocator = arr.allocator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#scope_file;
|
||||||
|
|
||||||
|
mem :: #import "jc/memory";
|
||||||
|
basic :: #import "Basic"; // @future
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#module_parameters(RUN_TESTS := false);
|
#module_parameters(RUN_TESTS := false);
|
||||||
|
|
||||||
#load "static_array.jai";
|
#load "static_array.jai";
|
||||||
|
#load "dynamic_array.jai";
|
||||||
|
|
||||||
#scope_module;
|
#scope_module;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ operator []= :: inline (a: *Static_Array, index: int, value: a.T, loc := #caller
|
||||||
|
|
||||||
for_expansion :: (a: *Static_Array, body: Code, flags: For_Flags) #expand {
|
for_expansion :: (a: *Static_Array, body: Code, flags: For_Flags) #expand {
|
||||||
view := make_view(a);
|
view := make_view(a);
|
||||||
for *=(flags & .POINTER == .POINTEr) <=(flags & .REVERSE == .REVERSE) `it, `it_index: iter {
|
for *=(flags & .POINTER == .POINTER) <=(flags & .REVERSE == .REVERSE) `it, `it_index: view {
|
||||||
#insert,scope(body)(break = break it) body;
|
#insert,scope(body)(break = break it) body;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +78,7 @@ make_dynamic :: (a: *Static_Array) -> [..]a.T {
|
||||||
#scope_file;
|
#scope_file;
|
||||||
|
|
||||||
ensure_array_has_room :: (array: *Static_Array, count: int, loc := #caller_location) #expand {
|
ensure_array_has_room :: (array: *Static_Array, count: int, loc := #caller_location) #expand {
|
||||||
basic.assert(array.count + count <= array.capacity, "attempt to add too many elements! want: %, Max: %", array.count + count, array.capacity, loc = loc);
|
basic.assert(array.count + count <= array.capacity, "attempt to add too many elements! want: %, max: %", array.count + count, array.capacity, loc = loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
mem :: #import "jc/memory";
|
mem :: #import "jc/memory";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue