'ô > BLib.MAllocA/src 1.05 15Sep2011 6ô Version A: checks last slot before scanning list ô (]ô v1.05 15Sep2011 JGH Extends last slot into free space, adds names to heap on first call 28ô v1.04 12Aug2006 JGH Checks for size of free memory <*ô v1.03 23Jul2006 JGH m_zalloc() added F+ô v1.02 15Sep1989 JGH m_realloc() added P?ô v1.01 08Sep1989 JGH Bug in reuse of released memory fixed Z8ô v1.00 06Sep1989 JGH m_alloc() and m_free() written d: n ô Memory Allocation Routines x ô ~~~~~~~~~~~~~~~~~~~~~~~~~~ ‚<ô *BUG* When scanning heap, when link=0, !0 is read from Œ: –:  Gݤm_alloc(size%):êA%,B%,E%:m_heap%=m_heap% :ô Create m_heap% ª\çm_heap%=0:òm_free(0) :ô If first call, add names to heap ´Hsize%=(size%+3)€-4:ÞE%-1:çsize%=0:=“-E%-1280 :ô Return free space ¾A%=m_heap% È^çA%:ç!A%<=size%:çA%+!A%+4=E%:ÞE%size%-!A%:!A%=size%:m_heap%=A%!4:=A%+4 :ô Extend last slot ÒOçA%:ç!A%< size%:õB%=A%:A%=A%!4:ý!A%>=size%„A%=0 :ô Scan for big enough slot ÜSçA%=0:ç“-E%-size%-1280<0:=0 :ô No slot, no free space æXçA%=0:ÞA%size%+3:!A%=size%:=A%+4 :ô No slot, claim new space ðW :ô Slot bigger than needed, split it úUç!A%>size%+7:A%!(size%+8)=A%!4:A%!(size%+4)=!A%-size%-4:A%!4=A%+size%+4:!A%=size% NçB%:B%!4=A%!4 ‹ m_heap%=A%!4 :ô Get link, point to next slot N=A%+4 :ô Return this claimed slot : ",Ýòm_free(ptr%):m_heap%=m_heap%:çptr%=0:á , !ptr%=m_heap%:m_heap%=ptr%-4 6Aç!ptr%=ptr%+ptr%!-4:ptr%!-4=ptr%!-4+!!ptr%+4:!ptr%=!(!ptr%+4) @á J: T:ݤm_realloc(ptr%,size%):òm_free(ptr%):=¤m_alloc(size%) ^: h>ݤm_zalloc(size%):êA%:A%=¤m_alloc(size%):çA%=0„size%<1:=A% r*õsize%=size%-1:A%?size%=0:ýsize%<0:=A% ÿ