1
This commit is contained in:
churl
2022-05-09 18:08:13 +02:00
parent f57b8fef27
commit f3ea150650
2 changed files with 11 additions and 2 deletions

View File

@ -35,7 +35,7 @@ void CGA_Stream::flush() {
pos = 0;
}
// Alternative way to write the templates which keeps definition separated
// Alternative way to write the templates which keeps definition/declaration separated
// Usable for our case but somehow defeats the purpose of templates
// template<typename T>
// T& operator<<(T& os, const fgc& fg) {

View File

@ -16,7 +16,13 @@
// Format eines freien Blocks, 4 + 4 + 4 Byte
struct free_block {
bool allocated; // NOTE: I added this to allow easier merging of free blocks
bool allocated; // NOTE: I added this to allow easier merging of free blocks:
// When freeing an allocated block, its next-pointer can
// point to another allocated block, the next free block
// can be found by traversing the leading allocated blocks.
// We only need a way to determine when the free block is reached.
// This also means that the whole list has to be traversed
// to merge blocks. Would be faster with doubly linked list.
unsigned int size;
struct free_block* next;
};
@ -30,6 +36,9 @@ private:
LinkedListAllocator(Allocator& copy); // Verhindere Kopieren
// NOTE: I added this
// Traverses the whole list forward till previous block is reached.
// This can only be called on free blocks as allocated blocks
// aren't reachable from the freelist.
struct free_block* find_previous_block(struct free_block*);
public: