(self, size:int, alignment:int=1)
| 5 | class BumpAllocator: |
| 6 | def __init__(self, size:int, base:int=0, wrap:bool=True): self.size, self.ptr, self.base, self.wrap = size, 0, base, wrap |
| 7 | def alloc(self, size:int, alignment:int=1) -> int: |
| 8 | if round_up(self.ptr, alignment) + size > self.size: |
| 9 | if not self.wrap: raise RuntimeError("Out of memory") |
| 10 | self.ptr = 0 |
| 11 | self.ptr = (res:=round_up(self.ptr, alignment)) + size |
| 12 | return res + self.base |
| 13 | |
| 14 | class TLSFAllocator: |
| 15 | """ |
no test coverage detected