aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2021-03-18 10:44:09 +0100
committerDanielGavin <danielgavin5@hotmail.com>2021-03-18 10:44:09 +0100
commit6ff8c1b780759d02156bf4c69c3c443ece12c160 (patch)
tree1ce5fc6f27310952b814670cf8bffc8ddccd532b /src/common
parent2313142359f69769b838b835f15c726d1ce2ebb4 (diff)
ran odinfmt
Diffstat (limited to 'src/common')
-rw-r--r--src/common/allocator.odin14
-rw-r--r--src/common/ast.odin40
-rw-r--r--src/common/fuzzy.odin26
-rw-r--r--src/common/pool.odin20
-rw-r--r--src/common/position.odin18
-rw-r--r--src/common/pretty.odin15
-rw-r--r--src/common/sha1.odin18
-rw-r--r--src/common/track_allocator.odin30
-rw-r--r--src/common/uri.odin19
9 files changed, 101 insertions, 99 deletions
diff --git a/src/common/allocator.odin b/src/common/allocator.odin
index a7bfae7..4f72f81 100644
--- a/src/common/allocator.odin
+++ b/src/common/allocator.odin
@@ -30,15 +30,15 @@ scratch_allocator_destroy :: proc (s: ^Scratch_Allocator) {
s^ = {};
}
-scratch_allocator_proc :: proc (allocator_data: rawptr, mode: mem.Allocator_Mode,
-size, alignment: int,
+scratch_allocator_proc :: proc (allocator_data: rawptr, mode: mem.Allocator_Mode,
+size, alignment: int,
old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> rawptr {
s := (^Scratch_Allocator)(allocator_data);
if s.data == nil {
DEFAULT_BACKING_SIZE :: 1 << 22;
- if !(context.allocator.procedure != scratch_allocator_proc &&
+ if !(context.allocator.procedure != scratch_allocator_proc &&
context.allocator.data != allocator_data) {
panic("cyclic initialization of the scratch allocator with itself");
}
@@ -54,7 +54,7 @@ old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> r
switch {
case s.curr_offset + size <= len(s.data):
start := uintptr(raw_data(s.data));
- ptr := start + uintptr(s.curr_offset);
+ ptr := start + uintptr(s.curr_offset);
ptr = mem.align_forward_uintptr(ptr, uintptr(alignment));
mem.zero(rawptr(ptr), size);
@@ -79,7 +79,7 @@ old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> r
case .Free:
case .Free_All:
- s.curr_offset = 0;
+ s.curr_offset = 0;
s.prev_allocation = nil;
for ptr in s.leaked_allocations {
free(ptr, s.backup_allocator);
@@ -87,8 +87,8 @@ old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> r
clear(&s.leaked_allocations);
case .Resize:
- begin := uintptr(raw_data(s.data));
- end := begin + uintptr(len(s.data));
+ begin := uintptr(raw_data(s.data));
+ end := begin + uintptr(len(s.data));
old_ptr := uintptr(old_memory);
//if begin <= old_ptr && old_ptr < end && old_ptr+uintptr(size) < end {
// s.curr_offset = int(old_ptr-begin)+size;
diff --git a/src/common/ast.odin b/src/common/ast.odin
index c807ce8..7532148 100644
--- a/src/common/ast.odin
+++ b/src/common/ast.odin
@@ -34,7 +34,7 @@ GlobalExpr :: struct {
}
//TODO(add a sub procedure to avoid repeating the value decl work)
-collect_globals :: proc (file: ast.File) -> []GlobalExpr {
+collect_globals :: proc(file: ast.File) -> []GlobalExpr {
exprs := make([dynamic]GlobalExpr, context.temp_allocator);
@@ -151,17 +151,18 @@ collect_globals :: proc (file: ast.File) -> []GlobalExpr {
return exprs[:];
}
-get_ast_node_string :: proc (node: ^ast.Node, src: []byte) -> string {
+get_ast_node_string :: proc(node: ^ast.Node, src: []byte) -> string {
return string(src[node.pos.offset:node.end.offset]);
}
-free_ast :: proc {
-free_ast_node,
-free_ast_array,
-free_ast_dynamic_array,
-free_ast_comment};
+free_ast :: proc{
+ free_ast_node,
+ free_ast_array,
+ free_ast_dynamic_array,
+ free_ast_comment,
+};
-free_ast_comment :: proc (a: ^ast.Comment_Group, allocator: mem.Allocator) {
+free_ast_comment :: proc(a: ^ast.Comment_Group, allocator: mem.Allocator) {
if a == nil {
return;
}
@@ -173,14 +174,14 @@ free_ast_comment :: proc (a: ^ast.Comment_Group, allocator: mem.Allocator) {
free(a, allocator);
}
-free_ast_array :: proc (array: $A/[]^$T, allocator: mem.Allocator) {
+free_ast_array :: proc(array: $A/[]^$T, allocator: mem.Allocator) {
for elem, i in array {
free_ast(elem, allocator);
}
delete(array, allocator);
}
-free_ast_dynamic_array :: proc (array: $A/[dynamic]^$T, allocator: mem.Allocator) {
+free_ast_dynamic_array :: proc(array: $A/[dynamic]^$T, allocator: mem.Allocator) {
for elem, i in array {
free_ast(elem, allocator);
}
@@ -188,7 +189,7 @@ free_ast_dynamic_array :: proc (array: $A/[dynamic]^$T, allocator: mem.Allocator
delete(array);
}
-free_ast_node :: proc (node: ^ast.Node, allocator: mem.Allocator) {
+free_ast_node :: proc(node: ^ast.Node, allocator: mem.Allocator) {
using ast;
@@ -397,7 +398,7 @@ free_ast_node :: proc (node: ^ast.Node, allocator: mem.Allocator) {
mem.free(node, allocator);
}
-free_ast_file :: proc (file: ast.File, allocator := context.allocator) {
+free_ast_file :: proc(file: ast.File, allocator := context.allocator) {
for decl in file.decls {
free_ast(decl, allocator);
@@ -414,12 +415,13 @@ free_ast_file :: proc (file: ast.File, allocator := context.allocator) {
delete(file.decls);
}
-node_equal :: proc {
-node_equal_node,
-node_equal_array,
-node_equal_dynamic_array};
+node_equal :: proc{
+ node_equal_node,
+ node_equal_array,
+ node_equal_dynamic_array,
+};
-node_equal_array :: proc (a, b: $A/[]^$T) -> bool {
+node_equal_array :: proc(a, b: $A/[]^$T) -> bool {
ret := true;
@@ -434,7 +436,7 @@ node_equal_array :: proc (a, b: $A/[]^$T) -> bool {
return ret;
}
-node_equal_dynamic_array :: proc (a, b: $A/[dynamic]^$T) -> bool {
+node_equal_dynamic_array :: proc(a, b: $A/[dynamic]^$T) -> bool {
ret := true;
@@ -449,7 +451,7 @@ node_equal_dynamic_array :: proc (a, b: $A/[dynamic]^$T) -> bool {
return ret;
}
-node_equal_node :: proc (a, b: ^ast.Node) -> bool {
+node_equal_node :: proc(a, b: ^ast.Node) -> bool {
using ast;
diff --git a/src/common/fuzzy.odin b/src/common/fuzzy.odin
index ccd8f0b..cf4d82c 100644
--- a/src/common/fuzzy.odin
+++ b/src/common/fuzzy.odin
@@ -77,7 +77,7 @@ char_types: []u8 = {
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
};
-make_fuzzy_matcher :: proc (pattern: string, allocator := context.temp_allocator) -> ^FuzzyMatcher {
+make_fuzzy_matcher :: proc(pattern: string, allocator := context.temp_allocator) -> ^FuzzyMatcher {
matcher := new(FuzzyMatcher, allocator);
@@ -116,7 +116,7 @@ make_fuzzy_matcher :: proc (pattern: string, allocator := context.temp_allocator
return matcher;
}
-fuzzy_to_acronym :: proc (word: string) -> (string, bool) {
+fuzzy_to_acronym :: proc(word: string) -> (string, bool) {
builder := strings.make_builder(context.temp_allocator);
@@ -149,7 +149,7 @@ fuzzy_to_acronym :: proc (word: string) -> (string, bool) {
return str, true;
}
-fuzzy_match :: proc (matcher: ^FuzzyMatcher, word: string) -> (f32, bool) {
+fuzzy_match :: proc(matcher: ^FuzzyMatcher, word: string) -> (f32, bool) {
if !fuzzy_init(matcher, word) {
return 0, false;
@@ -168,7 +168,7 @@ fuzzy_match :: proc (matcher: ^FuzzyMatcher, word: string) -> (f32, bool) {
fuzzy_build_graph(matcher);
best := max(cast(int)matcher.scores[matcher.pattern_count][matcher.word_count][miss].score,
- cast(int)matcher.scores[matcher.pattern_count][matcher.word_count][match].score);
+ cast(int)matcher.scores[matcher.pattern_count][matcher.word_count][match].score);
if fuzzy_is_awful(best) {
return 0.0, false;
@@ -183,11 +183,11 @@ fuzzy_match :: proc (matcher: ^FuzzyMatcher, word: string) -> (f32, bool) {
return score, true;
}
-fuzzy_is_awful :: proc (s: int) -> bool {
+fuzzy_is_awful :: proc(s: int) -> bool {
return s < awful_score / 2;
}
-fuzzy_calculate_roles :: proc (text: string, roles: ^[]FuzzyCharRole) -> FuzzyCharTypeSet {
+fuzzy_calculate_roles :: proc(text: string, roles: ^[]FuzzyCharRole) -> FuzzyCharTypeSet {
assert(len(text) == len(roles));
@@ -217,15 +217,15 @@ fuzzy_calculate_roles :: proc (text: string, roles: ^[]FuzzyCharRole) -> FuzzyCh
return type_set;
}
-fuzzy_rotate :: proc (t: FuzzyCharType, types: ^FuzzyCharType) {
+fuzzy_rotate :: proc(t: FuzzyCharType, types: ^FuzzyCharType) {
types^ = cast(FuzzyCharType)(((cast(uint)types^ << 2) | cast(uint)t) & 0x3f);
}
-fuzzy_packed_lookup :: proc (data: $A/[]$T, i: uint) -> T {
+fuzzy_packed_lookup :: proc(data: $A/[]$T, i: uint) -> T {
return (data[i >> 2] >> ((i & 3) * 2)) & 3;
}
-fuzzy_init :: proc (matcher: ^FuzzyMatcher, word: string) -> bool {
+fuzzy_init :: proc(matcher: ^FuzzyMatcher, word: string) -> bool {
matcher.word = word;
matcher.word_count = min(max_word, len(matcher.word));
@@ -259,7 +259,7 @@ fuzzy_init :: proc (matcher: ^FuzzyMatcher, word: string) -> bool {
return true;
}
-fuzzy_skip_penalty :: proc (matcher: ^FuzzyMatcher, w: int) -> int {
+fuzzy_skip_penalty :: proc(matcher: ^FuzzyMatcher, w: int) -> int {
if w == 0 { // Skipping the first character.
return 3;
@@ -272,7 +272,7 @@ fuzzy_skip_penalty :: proc (matcher: ^FuzzyMatcher, w: int) -> int {
return 0;
}
-fuzzy_build_graph :: proc (matcher: ^FuzzyMatcher) {
+fuzzy_build_graph :: proc(matcher: ^FuzzyMatcher) {
for w := 0; w < matcher.word_count; w += 1 {
@@ -340,7 +340,7 @@ fuzzy_build_graph :: proc (matcher: ^FuzzyMatcher) {
}
}
-fuzzy_match_bonus :: proc (matcher: ^FuzzyMatcher, p: int, w: int, last: int) -> int {
+fuzzy_match_bonus :: proc(matcher: ^FuzzyMatcher, p: int, w: int, last: int) -> int {
assert(matcher.lower_pattern[p] == matcher.lower_word[w]);
@@ -389,7 +389,7 @@ fuzzy_match_bonus :: proc (matcher: ^FuzzyMatcher, p: int, w: int, last: int) ->
return s;
}
-fuzzy_allow_match :: proc (matcher: ^FuzzyMatcher, p: int, w: int, last: int) -> bool {
+fuzzy_allow_match :: proc(matcher: ^FuzzyMatcher, p: int, w: int, last: int) -> bool {
if matcher.lower_pattern[p] != matcher.lower_word[w] {
return false;
diff --git a/src/common/pool.odin b/src/common/pool.odin
index 422b8f7..2efed98 100644
--- a/src/common/pool.odin
+++ b/src/common/pool.odin
@@ -12,7 +12,7 @@ Task_Status :: enum i32 {
Term,
}
-Task_Proc :: proc (task: ^Task);
+Task_Proc :: proc(task: ^Task);
Task :: struct {
procedure: Task_Proc,
@@ -33,8 +33,8 @@ Pool :: struct {
tasks: [dynamic]Task,
}
-pool_init :: proc (pool: ^Pool, thread_count: int, allocator := context.allocator) {
- worker_thread_internal :: proc (t: ^thread.Thread) {
+pool_init :: proc(pool: ^Pool, thread_count: int, allocator := context.allocator) {
+ worker_thread_internal :: proc(t: ^thread.Thread) {
pool := (^Pool)(t.data);
temp_allocator: Scratch_Allocator;
@@ -75,7 +75,7 @@ pool_init :: proc (pool: ^Pool, thread_count: int, allocator := context.allocato
}
}
-pool_destroy :: proc (pool: ^Pool) {
+pool_destroy :: proc(pool: ^Pool) {
delete(pool.tasks);
for t in &pool.threads {
@@ -88,13 +88,13 @@ pool_destroy :: proc (pool: ^Pool) {
sync.semaphore_destroy(&pool.sem_available);
}
-pool_start :: proc (pool: ^Pool) {
+pool_start :: proc(pool: ^Pool) {
for t in pool.threads {
thread.start(t);
}
}
-pool_join :: proc (pool: ^Pool) {
+pool_join :: proc(pool: ^Pool) {
pool.is_running = false;
sync.semaphore_post(&pool.sem_available, len(pool.threads));
@@ -106,7 +106,7 @@ pool_join :: proc (pool: ^Pool) {
}
}
-pool_add_task :: proc (pool: ^Pool, procedure: Task_Proc, data: rawptr, user_index: int = 0) {
+pool_add_task :: proc(pool: ^Pool, procedure: Task_Proc, data: rawptr, user_index: int = 0) {
sync.mutex_lock(&pool.mutex);
defer sync.mutex_unlock(&pool.mutex);
@@ -119,7 +119,7 @@ pool_add_task :: proc (pool: ^Pool, procedure: Task_Proc, data: rawptr, user_ind
sync.semaphore_post(&pool.sem_available, 1);
}
-pool_try_and_pop_task :: proc (pool: ^Pool) -> (task: Task, got_task: bool = false) {
+pool_try_and_pop_task :: proc(pool: ^Pool) -> (task: Task, got_task: bool = false) {
if sync.mutex_try_lock(&pool.mutex) {
if len(pool.tasks) != 0 {
intrinsics.atomic_add(&pool.processing_task_count, 1);
@@ -131,12 +131,12 @@ pool_try_and_pop_task :: proc (pool: ^Pool) -> (task: Task, got_task: bool = fal
return;
}
-pool_do_work :: proc (pool: ^Pool, task: ^Task) {
+pool_do_work :: proc(pool: ^Pool, task: ^Task) {
task.procedure(task);
intrinsics.atomic_sub(&pool.processing_task_count, 1);
}
-pool_wait_and_process :: proc (pool: ^Pool) {
+pool_wait_and_process :: proc(pool: ^Pool) {
for len(pool.tasks) != 0 || intrinsics.atomic_load(&pool.processing_task_count) != 0 {
if task, ok := pool_try_and_pop_task(pool); ok {
pool_do_work(pool, &task);
diff --git a/src/common/position.odin b/src/common/position.odin
index c409b2f..865d0c8 100644
--- a/src/common/position.odin
+++ b/src/common/position.odin
@@ -33,7 +33,7 @@ AbsoluteRange :: struct {
AbsolutePosition :: int;
-get_absolute_position :: proc (position: Position, document_text: []u8) -> (AbsolutePosition, bool) {
+get_absolute_position :: proc(position: Position, document_text: []u8) -> (AbsolutePosition, bool) {
absolute: AbsolutePosition;
if len(document_text) == 0 {
@@ -54,7 +54,7 @@ get_absolute_position :: proc (position: Position, document_text: []u8) -> (Abso
return absolute, true;
}
-get_relative_token_position :: proc (offset: int, document_text: []u8, current_start: int) -> Position {
+get_relative_token_position :: proc(offset: int, document_text: []u8, current_start: int) -> Position {
start_index := current_start;
@@ -91,10 +91,10 @@ get_relative_token_position :: proc (offset: int, document_text: []u8, current_s
/*
Get the range of a token in utf16 space
*/
-get_token_range :: proc (node: ast.Node, document_text: []u8) -> Range {
+get_token_range :: proc(node: ast.Node, document_text: []u8) -> Range {
range: Range;
- go_backwards_to_endline :: proc (offset: int, document_text: []u8) -> int {
+ go_backwards_to_endline :: proc(offset: int, document_text: []u8) -> int {
index := offset;
@@ -125,7 +125,7 @@ get_token_range :: proc (node: ast.Node, document_text: []u8) -> Range {
return range;
}
-get_absolute_range :: proc (range: Range, document_text: []u8) -> (AbsoluteRange, bool) {
+get_absolute_range :: proc(range: Range, document_text: []u8) -> (AbsoluteRange, bool) {
absolute: AbsoluteRange;
@@ -160,7 +160,7 @@ get_absolute_range :: proc (range: Range, document_text: []u8) -> (AbsoluteRange
return absolute, true;
}
-get_index_at_line :: proc (current_index: ^int, current_line: ^int, last: ^u8, document_text: []u8, end_line: int) -> bool {
+get_index_at_line :: proc(current_index: ^int, current_line: ^int, last: ^u8, document_text: []u8, end_line: int) -> bool {
if end_line == 0 {
current_index^ = 0;
@@ -199,7 +199,7 @@ get_index_at_line :: proc (current_index: ^int, current_line: ^int, last: ^u8, d
return false;
}
-get_character_offset_u16_to_u8 :: proc (character_offset: int, document_text: []u8) -> int {
+get_character_offset_u16_to_u8 :: proc(character_offset: int, document_text: []u8) -> int {
utf8_idx := 0;
utf16_idx := 0;
@@ -224,7 +224,7 @@ get_character_offset_u16_to_u8 :: proc (character_offset: int, document_text: []
return utf8_idx;
}
-get_character_offset_u8_to_u16 :: proc (character_offset: int, document_text: []u8) -> int {
+get_character_offset_u8_to_u16 :: proc(character_offset: int, document_text: []u8) -> int {
utf8_idx := 0;
utf16_idx := 0;
@@ -249,7 +249,7 @@ get_character_offset_u8_to_u16 :: proc (character_offset: int, document_text: []
return utf16_idx;
}
-get_end_line_u16 :: proc (document_text: []u8) -> int {
+get_end_line_u16 :: proc(document_text: []u8) -> int {
utf8_idx := 0;
utf16_idx := 0;
diff --git a/src/common/pretty.odin b/src/common/pretty.odin
index 929bf80..f7aa705 100644
--- a/src/common/pretty.odin
+++ b/src/common/pretty.odin
@@ -7,19 +7,20 @@ import "core:fmt"
Ast visualization to help in debugging and development
*/
-print_ast :: proc {
-print_ast_array,
-print_ast_dynamic_array,
-print_ast_node};
+print_ast :: proc{
+ print_ast_array,
+ print_ast_dynamic_array,
+ print_ast_node,
+};
-print_ast_array :: proc (array: $A/[]^$T, depth: int, src: []byte, newline := false) {
+print_ast_array :: proc(array: $A/[]^$T, depth: int, src: []byte, newline := false) {
for elem, i in array {
print_ast(elem, depth, src);
}
}
-print_ast_dynamic_array :: proc (array: $A/[dynamic]^$T, depth: int, src: []byte, newline := false) {
+print_ast_dynamic_array :: proc(array: $A/[dynamic]^$T, depth: int, src: []byte, newline := false) {
for elem, i in array {
print_ast(elem, depth, src);
@@ -30,7 +31,7 @@ print_ast_dynamic_array :: proc (array: $A/[dynamic]^$T, depth: int, src: []byte
Not fully printed out, filling it in as needed.
*/
-print_ast_node :: proc (node: ^ast.Node, depth: int, src: []byte, newline := false) {
+print_ast_node :: proc(node: ^ast.Node, depth: int, src: []byte, newline := false) {
using ast;
diff --git a/src/common/sha1.odin b/src/common/sha1.odin
index 67cbc4b..d4621dd 100644
--- a/src/common/sha1.odin
+++ b/src/common/sha1.odin
@@ -13,7 +13,7 @@ blk0 :: proc (buf: []u32, i: int) -> u32 {
}
blk :: proc (buf: []u32, i: int) -> u32 {
- buf[i & 15] = rol(buf[(i + 13) & 15] ~ buf[(i + 8) & 15] ~ buf[(i + 2) & 15] ~
+ buf[i & 15] = rol(buf[(i + 13) & 15] ~ buf[(i + 8) & 15] ~ buf[(i + 2) & 15] ~
buf[i & 15], 1);
return buf[i & 15];
@@ -181,7 +181,7 @@ sha1_add_uncounted :: proc (state_context: ^Sha1context, data: byte) {
when ODIN_ENDIAN == "big" {
state_context.buf.c[state_context.buf_offset] = data;
- } else
+ } else
{
state_context.buf.c[state_context.buf_offset ~ 3] = data;
@@ -225,9 +225,9 @@ sha1_update :: proc (state_context: ^Sha1context, data: []byte) {
for i := 0; i < BLOCK_LENGTH_32; i += 1 {
n := (transmute([]u32)current_data)[i];
- state_context.buf.l[i] = (((n & 0xFF) << 24) |
- ((n & 0xFF00) << 8) |
- ((n & 0xFF0000) >> 8) |
+ state_context.buf.l[i] = (((n & 0xFF) << 24) |
+ ((n & 0xFF00) << 8) |
+ ((n & 0xFF0000) >> 8) |
((n & 0xFF000000) >> 24));
}
@@ -267,13 +267,13 @@ sha1_final :: proc (state_context: ^Sha1context, result: ^[5]u32) {
for i := 0; i < 5; i += 1 {
result[i] = state_context.state[i];
}
- } else
+ } else
{
for i := 0; i < 5; i += 1 {
- result[i] = (((state_context.state[i]) << 24) & 0xff000000) |
- (((state_context.state[i]) << 8) & 0x00ff0000) |
- (((state_context.state[i]) >> 8) & 0x0000ff00) |
+ result[i] = (((state_context.state[i]) << 24) & 0xff000000) |
+ (((state_context.state[i]) << 8) & 0x00ff0000) |
+ (((state_context.state[i]) >> 8) & 0x0000ff00) |
(((state_context.state[i]) >> 24) & 0x000000ff);
}
}
diff --git a/src/common/track_allocator.odin b/src/common/track_allocator.odin
index afb1de2..978a74e 100644
--- a/src/common/track_allocator.odin
+++ b/src/common/track_allocator.odin
@@ -19,7 +19,7 @@ ThreadSafe_Allocator_Data :: struct {
// ----------------------------------------------------------------------------------------------------
-threadsafe_allocator :: proc (allocator: mem.Allocator) -> mem.Allocator {
+threadsafe_allocator :: proc(allocator: mem.Allocator) -> mem.Allocator {
data := new(ThreadSafe_Allocator_Data);
data.actual_allocator = allocator;
sync.mutex_init(&data.mutex);
@@ -29,7 +29,7 @@ threadsafe_allocator :: proc (allocator: mem.Allocator) -> mem.Allocator {
// ----------------------------------------------------------------------------------------------------
-threadsafe_allocator_proc :: proc (allocator_data: rawptr, mode: mem.Allocator_Mode, size, alignment: int,
+threadsafe_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, size, alignment: int,
old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> rawptr {
data := cast(^ThreadSafe_Allocator_Data)allocator_data;
@@ -62,7 +62,7 @@ Memleak_Entry :: struct {
// ----------------------------------------------------------------------------------------------------
-memleak_allocator_proc :: proc (allocator_data: rawptr, mode: mem.Allocator_Mode, size, alignment: int,
+memleak_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, size, alignment: int,
old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> rawptr {
memleak := cast(^Memleak_Allocator_Data)allocator_data;
@@ -91,10 +91,10 @@ old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> r
if memleak.track_frees {
memleak.frees[old_memory] = Memleak_Entry {
- location = loc,
- size = size,
- index = 0,
- };
+ location = loc,
+ size = size,
+ index = 0,
+ };
}
}
}
@@ -110,10 +110,10 @@ old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> r
// can be very useful for inspecting the stack trace of a particular allocation
memleak.allocations[result] = Memleak_Entry {
- location = loc,
- size = size,
- index = memleak.allocation_count,
- };
+ location = loc,
+ size = size,
+ index = memleak.allocation_count,
+ };
memleak.allocation_count += 1;
@@ -129,7 +129,7 @@ old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> r
// ----------------------------------------------------------------------------------------------------
-memleak_allocator :: proc (track_frees: bool) -> mem.Allocator {
+memleak_allocator :: proc(track_frees: bool) -> mem.Allocator {
make([]byte, 1, context.temp_allocator); // so the temp allocation doesn't clutter our results
@@ -149,7 +149,7 @@ memleak_allocator :: proc (track_frees: bool) -> mem.Allocator {
// ----------------------------------------------------------------------------------------------------
-memleak_detected_leaks :: proc () -> bool {
+memleak_detected_leaks :: proc() -> bool {
if context.allocator.procedure == memleak_allocator_proc {
memleak := cast(^Memleak_Allocator_Data)context.allocator.data;
return len(memleak.allocations) > 0;
@@ -160,7 +160,7 @@ memleak_detected_leaks :: proc () -> bool {
// ----------------------------------------------------------------------------------------------------
-memleak_dump :: proc (memleak_alloc: mem.Allocator, dump_proc: proc (message: string, user_data: rawptr), user_data: rawptr) {
+memleak_dump :: proc(memleak_alloc: mem.Allocator, dump_proc: proc(message: string, user_data: rawptr), user_data: rawptr) {
memleak := cast(^Memleak_Allocator_Data)memleak_alloc.data;
context.allocator = memleak.actual_allocator;
@@ -187,6 +187,6 @@ memleak_dump :: proc (memleak_alloc: mem.Allocator, dump_proc: proc (message: st
// ----------------------------------------------------------------------------------------------------
-log_dump :: proc (message: string, user_data: rawptr) {
+log_dump :: proc(message: string, user_data: rawptr) {
log.info(message);
}
diff --git a/src/common/uri.odin b/src/common/uri.odin
index b979634..ee25393 100644
--- a/src/common/uri.odin
+++ b/src/common/uri.odin
@@ -15,7 +15,7 @@ Uri :: struct {
//Note(Daniel, This is an extremely incomplete uri parser and for now ignores fragment and query and only handles file schema)
-parse_uri :: proc (value: string, allocator: mem.Allocator) -> (Uri, bool) {
+parse_uri :: proc(value: string, allocator: mem.Allocator) -> (Uri, bool) {
uri: Uri;
@@ -45,7 +45,7 @@ parse_uri :: proc (value: string, allocator: mem.Allocator) -> (Uri, bool) {
}
//Note(Daniel, Again some really incomplete and scuffed uri writer)
-create_uri :: proc (path: string, allocator: mem.Allocator) -> Uri {
+create_uri :: proc(path: string, allocator: mem.Allocator) -> Uri {
path_forward, _ := filepath.to_slash(path, context.temp_allocator);
builder := strings.make_builder(allocator);
@@ -53,8 +53,7 @@ create_uri :: proc (path: string, allocator: mem.Allocator) -> Uri {
//bad
when ODIN_OS == "windows" {
strings.write_string(&builder, "file:///");
- } else
- {
+ } else {
strings.write_string(&builder, "file://");
}
@@ -69,7 +68,7 @@ create_uri :: proc (path: string, allocator: mem.Allocator) -> Uri {
return uri;
}
-delete_uri :: proc (uri: Uri) {
+delete_uri :: proc(uri: Uri) {
if uri.uri != "" {
delete(uri.uri);
@@ -80,7 +79,7 @@ delete_uri :: proc (uri: Uri) {
}
}
-encode_percent :: proc (value: string, allocator: mem.Allocator) -> string {
+encode_percent :: proc(value: string, allocator: mem.Allocator) -> string {
builder := strings.make_builder(allocator);
@@ -94,8 +93,8 @@ encode_percent :: proc (value: string, allocator: mem.Allocator) -> string {
if r > 127 || r == ':' {
for i := 0; i < w; i += 1 {
- strings.write_string(&builder, strings.concatenate({"%", fmt.tprintf("%X", data[index + i])},
- context.temp_allocator));
+ strings.write_string(&builder, strings.concatenate({"%", fmt.tprintf("%X", data[index + i])},
+ context.temp_allocator));
}
} else {
strings.write_byte(&builder, data[index]);
@@ -108,7 +107,7 @@ encode_percent :: proc (value: string, allocator: mem.Allocator) -> string {
}
@(private)
-starts_with :: proc (value: string, starts_with: string) -> bool {
+starts_with :: proc(value: string, starts_with: string) -> bool {
if len(value) < len(starts_with) {
return false;
@@ -125,7 +124,7 @@ starts_with :: proc (value: string, starts_with: string) -> bool {
}
@(private)
-decode_percent :: proc (value: string, allocator: mem.Allocator) -> (string, bool) {
+decode_percent :: proc(value: string, allocator: mem.Allocator) -> (string, bool) {
builder := strings.make_builder(allocator);