func (h *Heap) Malloc(name string, size uint) {
	if size < 1 || size > MaxMalloc {
		fmt.Printf("Malloc(%d) is invalid, 0 < size <= %d\n", size, MaxMalloc)
		os.Exit(1)
	}
	log.Printf("Malloc(%d)\n", size)
	size += HdrSize
	slot := minPower2(size)
	char := strToUint(name)
	if _, ok := h.vars[char]; ok {
		fmt.Printf("Variable '%c' is already declared\n", char)
		os.Exit(1)
	}
	h.resetState()
	h.state[Type] = CheckAvail
	h.state[Slot] = slot
	h.state[Want] = slot
	h.state[Name] = strToUint(name)
}
Malloc allocates `size` amount of memory
package memsim
import (
	"log"
	"fmt"
	"os"
)
const (
	Idle = iota
	Split
	CheckAvail
	SetHead
	ValSet
	FreeSet
	BuddyChk
	BuddyFail
	BuddyMerge
	OutOfMem
)
const (
	NullPtr = 0b00011111  
	HdrSize  = 1
	CellSize = 2
	MinPwr   = 1
	MaxPwr   = 4
	NumSlots = MaxPwr - MinPwr + 1
	MaxMalloc = (1 << MaxPwr) - HdrSize
)
const (
	Type = "type"
	Slot = "slot"
	Want = "want"
	Loc  = "loc"
	Bdy  = "buddy"
	Name = "name"
)
type Heap struct {
	mem       []byte
	heads     []uint
	state     map[string]uint
	prevState map[string]uint
	vars      map[uint]uint
}
func NewHeap() *Heap {
	h := Heap{}
	h.mem = make([]byte, 1<<MaxPwr)
	h.heads = make([]uint, NumSlots)
	for i := range h.heads {
		h.heads[i] = NullPtr
	}
	h.insertCell(0, MaxPwr)
	h.state = make(map[string]uint)
	h.prevState = make(map[string]uint)
	h.vars = make(map[uint]uint)
	h.state[Type] = Idle
	h.prevState[Type] = Idle
	return &h
}