[kernel] Remove last of old allocator interface
Removing the `allocator.h` file defining the `kutil::allocator` interface, now that explicit allocators are not being passed around. Also removed the unused `frame_allocator::raw_allocator` class and `kutil::invalid_allocator` object. Tags: memory
This commit is contained in:
@@ -157,21 +157,4 @@ heap_allocator::pop_free(unsigned size)
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
class invalid_allocator :
|
||||
public allocator
|
||||
{
|
||||
public:
|
||||
virtual void * allocate(size_t) override {
|
||||
kassert(false, "Attempting to allocate from allocator::invalid");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void free(void *) override {
|
||||
kassert(false, "Attempting to free from allocator::invalid");
|
||||
}
|
||||
} _invalid_allocator;
|
||||
|
||||
allocator &allocator::invalid = _invalid_allocator;
|
||||
|
||||
} // namespace kutil
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
/// \file allocator.h
|
||||
/// Allocator interface
|
||||
|
||||
#include <stdint.h>
|
||||
#include "kernel_memory.h"
|
||||
|
||||
namespace kutil {
|
||||
|
||||
class allocator
|
||||
{
|
||||
public:
|
||||
/// Allocate memory.
|
||||
/// \arg length The amount of memory to allocate, in bytes
|
||||
/// \returns A pointer to the allocated memory, or nullptr if
|
||||
/// allocation failed.
|
||||
virtual void * allocate(size_t size) = 0;
|
||||
|
||||
/// Free a previous allocation.
|
||||
/// \arg p A pointer previously retuned by allocate()
|
||||
virtual void free(void *p) = 0;
|
||||
|
||||
template <typename T>
|
||||
inline T * allocate(unsigned count) {
|
||||
return reinterpret_cast<T*>(allocate(count * sizeof(T)));
|
||||
}
|
||||
|
||||
static allocator &invalid;
|
||||
};
|
||||
|
||||
} // namespace kutil
|
||||
@@ -3,14 +3,12 @@
|
||||
/// A buddy allocator for a memory heap
|
||||
|
||||
#include <stddef.h>
|
||||
#include "kutil/allocator.h"
|
||||
|
||||
namespace kutil {
|
||||
|
||||
|
||||
/// Allocator for a given heap range
|
||||
class heap_allocator :
|
||||
public allocator
|
||||
class heap_allocator
|
||||
{
|
||||
public:
|
||||
/// Default constructor creates a valid but empty heap.
|
||||
@@ -25,11 +23,11 @@ public:
|
||||
/// \arg length The amount of memory to allocate, in bytes
|
||||
/// \returns A pointer to the allocated memory, or nullptr if
|
||||
/// allocation failed.
|
||||
virtual void * allocate(size_t length) override;
|
||||
virtual void * allocate(size_t length);
|
||||
|
||||
/// Free a previous allocation.
|
||||
/// \arg p A pointer previously retuned by allocate()
|
||||
virtual void free(void *p) override;
|
||||
virtual void free(void *p);
|
||||
|
||||
/// Minimum block size is (2^min_size). Must be at least 6.
|
||||
static const unsigned min_size = 6;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include "kutil/allocator.h"
|
||||
#include "kutil/memory.h"
|
||||
|
||||
namespace kutil {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
/// Structure for tracking a range of virtual memory addresses
|
||||
|
||||
#include <stdint.h>
|
||||
#include "kutil/allocator.h"
|
||||
#include "kutil/avl_tree.h"
|
||||
|
||||
namespace kutil {
|
||||
|
||||
Reference in New Issue
Block a user