mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Add mem.tracking_allocator_reset
This commit is contained in:
@@ -47,6 +47,7 @@ tracking_allocator_destroy :: proc(t: ^Tracking_Allocator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Clear only the current allocation data while keeping the totals intact.
|
||||||
tracking_allocator_clear :: proc(t: ^Tracking_Allocator) {
|
tracking_allocator_clear :: proc(t: ^Tracking_Allocator) {
|
||||||
sync.mutex_lock(&t.mutex)
|
sync.mutex_lock(&t.mutex)
|
||||||
clear(&t.allocation_map)
|
clear(&t.allocation_map)
|
||||||
@@ -55,6 +56,19 @@ tracking_allocator_clear :: proc(t: ^Tracking_Allocator) {
|
|||||||
sync.mutex_unlock(&t.mutex)
|
sync.mutex_unlock(&t.mutex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset all of a Tracking Allocator's allocation data back to zero.
|
||||||
|
tracking_allocator_reset :: proc(t: ^Tracking_Allocator) {
|
||||||
|
sync.mutex_lock(&t.mutex)
|
||||||
|
clear(&t.allocation_map)
|
||||||
|
clear(&t.bad_free_array)
|
||||||
|
t.total_memory_allocated = 0
|
||||||
|
t.total_allocation_count = 0
|
||||||
|
t.total_memory_freed = 0
|
||||||
|
t.total_free_count = 0
|
||||||
|
t.peak_memory_allocated = 0
|
||||||
|
t.current_memory_allocated = 0
|
||||||
|
sync.mutex_unlock(&t.mutex)
|
||||||
|
}
|
||||||
|
|
||||||
@(require_results)
|
@(require_results)
|
||||||
tracking_allocator :: proc(data: ^Tracking_Allocator) -> Allocator {
|
tracking_allocator :: proc(data: ^Tracking_Allocator) -> Allocator {
|
||||||
|
|||||||
Reference in New Issue
Block a user