mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-11-04 00:49:02 -06:00 
			
		
		
		
	Core: Use std::array for managing kernel object space
These avoid relying on memset for clearing the arrays.
This commit is contained in:
		@@ -17,7 +17,6 @@ Handle g_main_thread = 0;
 | 
			
		||||
ObjectPool g_object_pool;
 | 
			
		||||
 | 
			
		||||
ObjectPool::ObjectPool() {
 | 
			
		||||
    memset(occupied, 0, sizeof(bool) * MAX_COUNT);
 | 
			
		||||
    next_id = INITIAL_NEXT_ID;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -57,7 +56,7 @@ void ObjectPool::Clear() {
 | 
			
		||||
            delete pool[i];
 | 
			
		||||
        occupied[i] = false;
 | 
			
		||||
    }
 | 
			
		||||
    memset(pool, 0, sizeof(Object*)*MAX_COUNT);
 | 
			
		||||
    pool.fill(nullptr);
 | 
			
		||||
    next_id = INITIAL_NEXT_ID;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <array>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include "common/common.h"
 | 
			
		||||
 | 
			
		||||
@@ -160,9 +161,9 @@ private:
 | 
			
		||||
        INITIAL_NEXT_ID = 0x10,
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Object* pool[MAX_COUNT];
 | 
			
		||||
    bool    occupied[MAX_COUNT];
 | 
			
		||||
    int     next_id;
 | 
			
		||||
    std::array<Object*, MAX_COUNT> pool;
 | 
			
		||||
    std::array<bool, MAX_COUNT> occupied;
 | 
			
		||||
    int next_id;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern ObjectPool g_object_pool;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user