Strip semicolons

This commit is contained in:
gingerBill
2021-09-19 11:59:44 +01:00
parent ceebd7b23c
commit ee876ad66b
20 changed files with 517 additions and 514 deletions
+34 -34
View File
@@ -6,25 +6,25 @@ import "core:mem"
import win32 "core:sys/windows"
heap_alloc :: proc(size: int) -> rawptr {
return win32.HeapAlloc(win32.GetProcessHeap(), win32.HEAP_ZERO_MEMORY, uint(size));
return win32.HeapAlloc(win32.GetProcessHeap(), win32.HEAP_ZERO_MEMORY, uint(size))
}
heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr {
if new_size == 0 {
heap_free(ptr);
return nil;
heap_free(ptr)
return nil
}
if ptr == nil {
return heap_alloc(new_size);
return heap_alloc(new_size)
}
return win32.HeapReAlloc(win32.GetProcessHeap(), win32.HEAP_ZERO_MEMORY, ptr, uint(new_size));
return win32.HeapReAlloc(win32.GetProcessHeap(), win32.HEAP_ZERO_MEMORY, ptr, uint(new_size))
}
heap_free :: proc(ptr: rawptr) {
if ptr == nil {
return;
return
}
win32.HeapFree(win32.GetProcessHeap(), 0, ptr);
win32.HeapFree(win32.GetProcessHeap(), 0, ptr)
}
_heap_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode,
@@ -38,70 +38,70 @@ _heap_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode,
//
aligned_alloc :: proc(size, alignment: int, old_ptr: rawptr = nil) -> ([]byte, mem.Allocator_Error) {
a := max(alignment, align_of(rawptr));
space := size + a - 1;
a := max(alignment, align_of(rawptr))
space := size + a - 1
allocated_mem: rawptr;
allocated_mem: rawptr
if old_ptr != nil {
original_old_ptr := mem.ptr_offset((^rawptr)(old_ptr), -1)^;
allocated_mem = heap_resize(original_old_ptr, space+size_of(rawptr));
original_old_ptr := mem.ptr_offset((^rawptr)(old_ptr), -1)^
allocated_mem = heap_resize(original_old_ptr, space+size_of(rawptr))
} else {
allocated_mem = heap_alloc(space+size_of(rawptr));
allocated_mem = heap_alloc(space+size_of(rawptr))
}
aligned_mem := rawptr(mem.ptr_offset((^u8)(allocated_mem), size_of(rawptr)));
aligned_mem := rawptr(mem.ptr_offset((^u8)(allocated_mem), size_of(rawptr)))
ptr := uintptr(aligned_mem);
aligned_ptr := (ptr - 1 + uintptr(a)) & -uintptr(a);
diff := int(aligned_ptr - ptr);
ptr := uintptr(aligned_mem)
aligned_ptr := (ptr - 1 + uintptr(a)) & -uintptr(a)
diff := int(aligned_ptr - ptr)
if (size + diff) > space {
return nil, .Out_Of_Memory;
return nil, .Out_Of_Memory
}
aligned_mem = rawptr(aligned_ptr);
mem.ptr_offset((^rawptr)(aligned_mem), -1)^ = allocated_mem;
aligned_mem = rawptr(aligned_ptr)
mem.ptr_offset((^rawptr)(aligned_mem), -1)^ = allocated_mem
return mem.byte_slice(aligned_mem, size), nil;
return mem.byte_slice(aligned_mem, size), nil
}
aligned_free :: proc(p: rawptr) {
if p != nil {
heap_free(mem.ptr_offset((^rawptr)(p), -1)^);
heap_free(mem.ptr_offset((^rawptr)(p), -1)^)
}
}
aligned_resize :: proc(p: rawptr, old_size: int, new_size: int, new_alignment: int) -> ([]byte, mem.Allocator_Error) {
if p == nil {
return nil, nil;
return nil, nil
}
return aligned_alloc(new_size, new_alignment, p);
return aligned_alloc(new_size, new_alignment, p)
}
switch mode {
case .Alloc:
return aligned_alloc(size, alignment);
return aligned_alloc(size, alignment)
case .Free:
aligned_free(old_memory);
aligned_free(old_memory)
case .Free_All:
return nil, .Mode_Not_Implemented;
return nil, .Mode_Not_Implemented
case .Resize:
if old_memory == nil {
return aligned_alloc(size, alignment);
return aligned_alloc(size, alignment)
}
return aligned_resize(old_memory, old_size, size, alignment);
return aligned_resize(old_memory, old_size, size, alignment)
case .Query_Features:
set := (^mem.Allocator_Mode_Set)(old_memory);
set := (^mem.Allocator_Mode_Set)(old_memory)
if set != nil {
set^ = {.Alloc, .Free, .Resize, .Query_Features};
set^ = {.Alloc, .Free, .Resize, .Query_Features}
}
return nil, nil;
return nil, nil
case .Query_Info:
return nil, nil;
return nil, nil
}
return nil, nil;
return nil, nil
}