change align_forward to align_to
This commit is contained in:
parent
606bf14ffe
commit
c72c27fc81
3 changed files with 5 additions and 9 deletions
|
|
@ -92,7 +92,7 @@ arena_alloc :: (a: *Arena, count: int, alignment := Default_Align, loc := #calle
|
|||
basic.assert(power_of_two(alignment));
|
||||
|
||||
end := a.memory.(*u8) + a.offset;
|
||||
ptr := align_forward(end.(int), alignment);
|
||||
ptr := align_to(end.(int), alignment);
|
||||
total_size := (count + ptr.(*u8) - end.(*u8)).(u64);
|
||||
|
||||
basic.assert(a.offset + total_size <= a.memory_size, "arena: out of memory", loc = loc);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ power_of_two :: (x: int) -> bool {
|
|||
return x & (x - 1) == 0;
|
||||
}
|
||||
|
||||
align_forward :: (ptr: int, align: int = Default_Align) -> int {
|
||||
align_to :: (ptr: int, align: int = Default_Align) -> int {
|
||||
basic.assert(power_of_two(align), "alignment must be a power of two");
|
||||
|
||||
p := ptr;
|
||||
|
|
@ -74,7 +74,7 @@ allocator_restore :: (save_point: int) {
|
|||
|
||||
request_memory :: (size: int, align := Default_Align) -> *void {
|
||||
allocator := context.allocator;
|
||||
aligned_size := align_forward(size, align);
|
||||
aligned_size := align_to(size, align);
|
||||
return allocator.proc(xx Extended_Allocator_Mode.request_memory, aligned_size.(int), 0, null, allocator.data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ reload_main :: () {
|
|||
system_allocator := context.allocator;
|
||||
|
||||
// Ensure we're not allocating anywhere unexpected
|
||||
context.allocator = mem.Crash_Allocator;
|
||||
context.allocator = mem.make_crash_allocator();
|
||||
|
||||
basic.set_working_directory(strings.path_strip_filename(system.get_path_of_running_executable()));
|
||||
|
||||
|
|
@ -34,11 +34,7 @@ reload_main :: () {
|
|||
lib_arena: mem.Arena;
|
||||
mem.init_arena(*lib_arena, lib_memory, H.max_memory);
|
||||
|
||||
lib_allocator := Allocator.{
|
||||
proc = mem.arena_allocator_proc,
|
||||
data = *lib_arena,
|
||||
};
|
||||
|
||||
lib_allocator := mem.make_arena_allocator(*lib_arena);
|
||||
lib_state := basic.alloc(xx H.state_size,, allocator = lib_allocator);
|
||||
|
||||
H.init(lib_state, lib_allocator, true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue