调整了上传规则

This commit is contained in:
2026-07-19 11:44:01 +08:00
parent 639f418530
commit 0c6339ca5e
24 changed files with 34 additions and 107 deletions

View File

@@ -3,6 +3,7 @@ from stdint import *
import string
import atom
import viperio
import stdio
# ============================================================
# memhub - 统一内存管理库
@@ -413,17 +414,28 @@ class MemBuddy(MemManager):
# === 虚函数覆盖 ===
def alloc(self, size: t.CSizeT) -> t.CVoid | t.CPtr:
stdio.printf("DBG MemBuddy.alloc: size=%lu\n", size)
stdio.fflush(None)
self._lock()
result: t.CVoid | t.CPtr = None
if self.usable is not None:
stdio.printf("DBG MemBuddy.alloc: usable=%p\n", self.usable)
stdio.fflush(None)
if size != 0:
needed: t.CSizeT = size + MEMBUDDY_HEADER_SIZE
order: t.CInt = self._order_for_size(needed)
stdio.printf("DBG MemBuddy.alloc: order=%d max_order=%d\n", order, self.max_order)
stdio.fflush(None)
if order <= self.max_order:
block: t.CVoid | t.CPtr = self._split_to_order(order)
stdio.printf("DBG MemBuddy.alloc: block=%p\n", block)
stdio.fflush(None)
if block is not None:
c.DerefAs(block, t.CVoid(t.CUInt64T((order << 1) | 1), t.CPtr))
result = t.CVoid(t.CUInt64T(block) + MEMBUDDY_HEADER_SIZE, t.CPtr)
else:
stdio.printf("DBG MemBuddy.alloc: usable is None!\n")
stdio.fflush(None)
self._unlock()
return result