begin ; ! Forget loaded files

include  "inc:util.imp"
include  "inc:dict.imp"

record (dictf)name  d
string (255)s,param
integername  w1,w2
integer  tag,sym,freed = 0

predicate  chosen
string (255)t
  if  param=",*," start 
    printstring(s); newline
    true 
  finish 
  if  param=",," start 
    printstring(s); prompt(" ")
    readsymbol(sym) and  sym=sym&95 until  sym='Y' or  sym='N' or  sym=nl
    if  sym='Y' start 
      readsymbol(sym) while  sym#nl
      true 
    finish 
    readsymbol(sym) while  sym#nl
    false 
  finish 
  t = ",".s.","
  trueif  param -> (t)
  false 
end 

param = ",".cliparam.","
prompt(" ")
restart:
d == fildict
cycle 
  tag = d_beg+8
  while  tag<d_pos cycle 
    tag = tag+4 until  byteinteger(tag)=0
    tag = tag+4
    w1 == integer(tag); w2 == integer(tag+4)
    if  (w2+3)>>2=(freebot+3)>>2 and  w1<w2 start 
      transname(tag,s)
      if  chosen start 
        freed = freed+w2-w1
        freebot = w1
        w1 = -1; w2 = -1
        ->restart
      finish 
    finish 
    tag = tag+8
  repeat 
  exitif  d_alt=0
  d == record(d_alt)
repeat 
write((freed+512)>>10,0); printstring(" kbytes freed"); newline

endofprogram