Skip to content
AllocatorResetStats

AllocatorResetStats

Description

Zero every counter on self. peak_bytes_in_use is reset to the current bytes_in_use so subsequent peak tracking is monotonically correct from this point forward. self is run through ValidateAllocator first, so a structurally invalid allocator aborts before any state is touched.

Parameters

Name Direction Description
self in,out Allocator base whose counters are reset.

Success

Function returns. All counters except bytes_in_use and peak_bytes_in_use are zero; both of those equal the pre-call bytes_in_use.

Failure

Does not return - ValidateAllocator aborts via LOG_FATAL when self is NULL or structurally invalid.

Usage example (Cross-references)

Usage examples (Cross-references)
    
    #if FEATURE_ALLOC_STATS
    void AllocatorResetStats(Allocator *self) {
        ValidateAllocator(self);
        u64 in_use  = self->stats.bytes_in_use;
    static bool test_al_reset_stats_validates_magic(void) {
        Allocator a = mock_make_bad_magic();
        AllocatorResetStats(&a); // real -> LOG_FATAL
        return false;
    }
        u64 outstanding = AllocatorBytesInUse(alloc);
    
        AllocatorResetStats(alloc);
    
        bool ok = (outstanding != 0u) &&                          // there really was usage
Last updated on