From 0ee8b7a4e4a26addb7db06830732528e7fdefe37 Mon Sep 17 00:00:00 2001 From: Able Date: Sun, 24 Nov 2024 11:08:22 -0600 Subject: [PATCH] janky error handling --- sysdata/libraries/stn/src/alloc/block_alloc.hb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sysdata/libraries/stn/src/alloc/block_alloc.hb b/sysdata/libraries/stn/src/alloc/block_alloc.hb index b0917bd..6f27fa4 100644 --- a/sysdata/libraries/stn/src/alloc/block_alloc.hb +++ b/sysdata/libraries/stn/src/alloc/block_alloc.hb @@ -1,4 +1,4 @@ -.{log} := @use("../lib.hb") +.{log, panic} := @use("../lib.hb") alloc_return := @use("alloc_return.hb") /* the block size is 64 bytes, 64 blocks of 64 bytes. @@ -17,7 +17,7 @@ BlockAlloc := struct { offset := 1 a := 1 loop { - // a = self.state >> offset; + // a = self.state >> offset // check if the `offset` bit is 1, if it is move to the next offset if a == 1 { offset += 1 @@ -26,7 +26,12 @@ BlockAlloc := struct { // self it to 1 and return the ptr to the allocation self.state |= a // return ptr + offset * 64 - return .(64, self.ptr + offset * 64) + if self.ptr != null { + return .(64, self.ptr + offset * 64) + } else { + // panic.panic("Allocator is not inited.\0") + // return .(0, null) + } } // there are only 64 blocks if offset >= 64 {