"""
Auto-generated Python stub file from mpool.py
Module: mpool
"""


import t, c
from stdint import *
import viperio
import string

MPOOL_ALIGN: t.CDefine = 8
MPOOL_TYPE_SLAB: t.CDefine = 0
MPOOL_TYPE_BUMP: t.CDefine = 2

def _align_up(val: t.CSizeT, align: t.CSizeT) -> t.CSizeT: pass


class MPool:
    mtype: t.CInt
    mem: t.CVoid | t.CPtr
    mem_size: t.CSizeT
    offset: t.CSizeT
    high_water: t.CSizeT
    block_size: t.CSizeT
    block_count: t.CSizeT
    used_count: t.CSizeT
    free_list: t.CVoid | t.CPtr
    alloc_map: t.CUInt8T | t.CPtr
    alloc_map_size: t.CSizeT
    def __init__(self: MPool, mem: t.CVoid | t.CPtr, mem_size: t.CSizeT, block_size: t.CSizeT) -> t.CInt: pass
    def _init_bump(self: MPool, mem: t.CVoid | t.CPtr, mem_size: t.CSizeT) -> t.CInt: pass
    def _init_slab(self: MPool, mem: t.CVoid | t.CPtr, mem_size: t.CSizeT, block_size: t.CSizeT) -> t.CInt: pass
    def __enter__(self: MPool) -> 'MPool' | t.CPtr: pass
    def __exit__(self: MPool) -> t.CInt: pass
    def _slab_reset(self: MPool) -> t.CInt: pass
    def alloc(self: MPool, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
    def alloc_buf(self: MPool, capacity: t.CSizeT) -> viperio.Buf | t.CPtr: pass
    def free(self: MPool, ptr: t.CVoid | t.CPtr) -> t.CInt: pass
    def realloc(self: MPool, ptr: t.CVoid | t.CPtr, old_size: t.CSizeT, new_size: t.CSizeT) -> t.CVoid | t.CPtr: pass
    def reset(self: MPool) -> t.CInt: pass
    def _bump_alloc(self: MPool, size: t.CSizeT) -> t.CVoid | t.CPtr: pass
    def _slab_alloc(self: MPool) -> t.CVoid | t.CPtr: pass
    def _slab_free(self: MPool, ptr: t.CVoid | t.CPtr) -> t.CInt: pass

def bump_create(mem: t.CVoid | t.CPtr, mem_size: t.CSizeT) -> MPool | t.CPtr: pass

def alloc(pool: MPool | t.CPtr, size: t.CSizeT) -> t.CVoid | t.CPtr: pass

def reset(pool: MPool | t.CPtr) -> t.CInt: pass
