mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 05:02:45 +00:00 
			
		
		
		
	 f820917a76
			
		
	
	
		f820917a76
		
	
	
	
	
		
			
			This commit converts naked `new`s to `AK::try_make` and `AK::try_create` wherever possible. If the called constructor is private, this can not be done, so we instead now use the standard-defined and compiler-agnostic `new (nothrow)`.
		
			
				
	
	
		
			44 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <Kernel/VM/ContiguousVMObject.h>
 | |
| #include <Kernel/VM/MemoryManager.h>
 | |
| #include <Kernel/VM/PhysicalPage.h>
 | |
| 
 | |
| namespace Kernel {
 | |
| 
 | |
| RefPtr<ContiguousVMObject> ContiguousVMObject::create_with_size(size_t size, size_t physical_alignment)
 | |
| {
 | |
|     auto contiguous_physical_pages = MM.allocate_contiguous_supervisor_physical_pages(size, physical_alignment);
 | |
|     if (contiguous_physical_pages.is_empty())
 | |
|         return {};
 | |
|     return adopt_ref_if_nonnull(new (nothrow) ContiguousVMObject(size, contiguous_physical_pages));
 | |
| }
 | |
| 
 | |
| ContiguousVMObject::ContiguousVMObject(size_t size, NonnullRefPtrVector<PhysicalPage>& contiguous_physical_pages)
 | |
|     : VMObject(size)
 | |
| {
 | |
|     for (size_t i = 0; i < page_count(); i++) {
 | |
|         physical_pages()[i] = contiguous_physical_pages[i];
 | |
|         dbgln_if(CONTIGUOUS_VMOBJECT_DEBUG, "Contiguous page[{}]: {}", i, physical_pages()[i]->paddr());
 | |
|     }
 | |
| }
 | |
| 
 | |
| ContiguousVMObject::ContiguousVMObject(const ContiguousVMObject& other)
 | |
|     : VMObject(other)
 | |
| {
 | |
| }
 | |
| 
 | |
| ContiguousVMObject::~ContiguousVMObject()
 | |
| {
 | |
| }
 | |
| 
 | |
| RefPtr<VMObject> ContiguousVMObject::clone()
 | |
| {
 | |
|     VERIFY_NOT_REACHED();
 | |
| }
 | |
| 
 | |
| }
 |