From 6c8b5281c2edb9a0e3e63c97e66ae4d548d5e49a Mon Sep 17 00:00:00 2001 From: NullSablex <244216261+NullSablex@users.noreply.github.com> Date: Mon, 31 Aug 2026 03:56:33 -0300 Subject: [PATCH] feat(amx): add Amx::hlw() accessor for the heap low-water mark MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Espelha heap()/stp(): expõe o registrador hlw (fundo do heap). Um debugger precisa dele para detectar heap underflow (AMX_ERR_HEAPLOW) num debug hook, antes de a VM abortar — sem cutucar o *mut AMX cru. --- samp-sdk/src/amx.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/samp-sdk/src/amx.rs b/samp-sdk/src/amx.rs index 7a6562b..ee1bbbf 100644 --- a/samp-sdk/src/amx.rs +++ b/samp-sdk/src/amx.rs @@ -561,6 +561,15 @@ impl Amx { read_reg!(self.stp) } + /// Heap low-water mark (`hlw`) — the bottom of the heap segment. The heap + /// grows upward from here; releasing it below `hlw` is what the VM reports as + /// `AMX_ERR_HEAPLOW`. A debugger reads it in a debug hook to detect a heap + /// underflow before the VM aborts. + #[must_use] + pub fn hlw(&self) -> Option { + read_reg!(self.hlw) + } + /// Primary register (`pri`) — the VM's main accumulator. In a debug hook it /// holds the operand the next instruction will act on; e.g. for `OP_BOUNDS` /// it is the index being range-checked.