defer in alloc
This commit is contained in:
parent
8b2b50e433
commit
8c88c0b5ae
|
@ -28,6 +28,8 @@ The policy on magic numbers is make them const and have a comment above them. Ty
|
||||||
|
|
||||||
This helps cut down on magic numbers while making acceptable names and atleast half assed documentation.
|
This helps cut down on magic numbers while making acceptable names and atleast half assed documentation.
|
||||||
|
|
||||||
|
Constants are inlined anyways, so its the same thing in the binary.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// The standard vga port is mapped at 0xB8000
|
// The standard vga port is mapped at 0xB8000
|
||||||
$VGA_PTR := 0xB8000
|
$VGA_PTR := 0xB8000
|
||||||
|
|
|
@ -15,6 +15,7 @@ main := fn(): void {
|
||||||
// alloc.deinit()
|
// alloc.deinit()
|
||||||
|
|
||||||
balloc := allocators.BlockAlloc.init()
|
balloc := allocators.BlockAlloc.init()
|
||||||
|
defer balloc.deinit()
|
||||||
bstruct := balloc.alloc(AStruct, 2)
|
bstruct := balloc.alloc(AStruct, 2)
|
||||||
if bstruct.ptr == null {
|
if bstruct.ptr == null {
|
||||||
log.info("Hi\0")
|
log.info("Hi\0")
|
||||||
|
@ -23,6 +24,5 @@ main := fn(): void {
|
||||||
log.info("Allocator functioned.\0")
|
log.info("Allocator functioned.\0")
|
||||||
}
|
}
|
||||||
// balloc.dealloc(bstruct_ptr, AStruct, 2)
|
// balloc.dealloc(bstruct_ptr, AStruct, 2)
|
||||||
// balloc.deinit()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
Loading…
Reference in a new issue