10
20
30
40
50
60
70
80
90
100 :
110
120
130
140 :
150 DEFFNm_alloc(size%):LOCALA%,B%,E%:m_heap%=m_heap%:IFm_heap%=0:PROCm_free(0)
160 size%=(size%+3)AND-4:DIME%-1:IFsize%=0:=HIMEM-E%-1280
170 A%=m_heap%:IFA%:IF!A%<=size%:IFA%+!A%+4=E%:DIME%size%-!A%:!A%=size%:m_heap%=A%!4:=A%+4
180 IFA%:IF!A%<size%:REPEATB%=A%:A%=A%!4:UNTIL!A%>=size%ORA%=0
190 IFA%=0:IFHIMEM-E%-size%-1280<0:=0
200 IFA%=0:DIMA%size%+3:!A%=size%:=A%+4
210 IF!A%>size%+7:A%!(size%+8)=A%!4:A%!(size%+4)=!A%-size%-4:A%!4=A%+size%+4:!A%=size%
220 IFB%:B%!4=A%!4 ELSE m_heap%=A%!4
230 =A%+4
240 :
250 DEFPROCm_free(ptr%):m_heap%=m_heap%:IFptr%=0:ENDPROC
260 !ptr%=m_heap%:m_heap%=ptr%-4
270 IF!ptr%=ptr%+ptr%!-4:ptr%!-4=ptr%!-4+!!ptr%+4:!ptr%=!(!ptr%+4)
280 ENDPROC
290 :
300 DEFFNm_realloc(ptr%,size%):PROCm_free(ptr%):=FNm_alloc(size%)
310 :
320 DEFFNm_zalloc(size%):LOCALA%:A%=FNm_alloc(size%):IFA%=0ORsize%<1:=A%
330 REPEATsize%=size%-1:A%?size%=0:UNTILsize%<0:=A%