mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-20 21:35:19 +00:00
Merge pull request #4836 from laytan/fix-wrong-out-of-memory
fix wrong out of memory in edge cases, just try allocate from block for one source of truth
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package test_core_mem
|
||||
|
||||
import "core:mem/tlsf"
|
||||
import "core:mem/virtual"
|
||||
import "core:testing"
|
||||
|
||||
@test
|
||||
@@ -38,4 +39,18 @@ test_tlsf_bitscan :: proc(t: ^testing.T) {
|
||||
testing.expectf(t, res == test.exp, "Expected tlsf.fls_uint(0x%16x) == %v, got %v", test.v, test.exp, res)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_align_bumping_block_limit :: proc(t: ^testing.T) {
|
||||
a: virtual.Arena
|
||||
defer virtual.arena_destroy(&a)
|
||||
|
||||
data, err := virtual.arena_alloc(&a, 4193371, 1)
|
||||
testing.expect_value(t, err, nil)
|
||||
testing.expect(t, len(data) == 4193371)
|
||||
|
||||
data, err = virtual.arena_alloc(&a, 896, 64)
|
||||
testing.expect_value(t, err, nil)
|
||||
testing.expect(t, len(data) == 896)
|
||||
}
|
||||
|
||||
@@ -31,6 +31,21 @@ test_temp_allocator_big_alloc_and_alignment :: proc(t: ^testing.T) {
|
||||
testing.expect(t, err == nil)
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_align_bumping_block_limit :: proc(t: ^testing.T) {
|
||||
a: runtime.Arena
|
||||
a.minimum_block_size = 8*mem.Megabyte
|
||||
defer runtime.arena_destroy(&a)
|
||||
|
||||
data, err := runtime.arena_alloc(&a, 4193371, 1)
|
||||
testing.expect_value(t, err, nil)
|
||||
testing.expect(t, len(data) == 4193371)
|
||||
|
||||
data, err = runtime.arena_alloc(&a, 896, 64)
|
||||
testing.expect_value(t, err, nil)
|
||||
testing.expect(t, len(data) == 896)
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_temp_allocator_returns_correct_size :: proc(t: ^testing.T) {
|
||||
arena: runtime.Arena
|
||||
|
||||
Reference in New Issue
Block a user