From f3ea150650e7a637679161818603a25f901cf285 Mon Sep 17 00:00:00 2001 From: churl Date: Mon, 9 May 2022 18:08:13 +0200 Subject: [PATCH] comments --- c_os/devices/CGA_Stream.cc | 2 +- c_os/kernel/allocator/LinkedListAllocator.h | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/c_os/devices/CGA_Stream.cc b/c_os/devices/CGA_Stream.cc index 241c8b2..791f47d 100755 --- a/c_os/devices/CGA_Stream.cc +++ b/c_os/devices/CGA_Stream.cc @@ -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 // T& operator<<(T& os, const fgc& fg) { diff --git a/c_os/kernel/allocator/LinkedListAllocator.h b/c_os/kernel/allocator/LinkedListAllocator.h index 4ac2a72..d2a67bb 100755 --- a/c_os/kernel/allocator/LinkedListAllocator.h +++ b/c_os/kernel/allocator/LinkedListAllocator.h @@ -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: