X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/e27ef2c6aab3a2a8051314bd37bb3b2386775f36..6dc5aa808483fdb8531afc990f26f1138bf2ddac:/bsearchtree.pas?ds=inline diff --git a/bsearchtree.pas b/bsearchtree.pas index d9e3ea2..9dc355e 100644 --- a/bsearchtree.pas +++ b/bsearchtree.pas @@ -32,6 +32,9 @@ procedure deltree(t:phashtable;s:ansistring); {returns the item pointer for s, or nil if not found} function findtree(t:phashtable;s:ansistring):pointer; +{clear a hashtable, deallocating all used resources} +procedure cleartree(t:phashtable); + implementation function makehash(s:ansistring):integer; @@ -98,4 +101,20 @@ begin end; end; +procedure cleartree(t:phashtable); +var + hash:integer; + p,p2:thashitem; +begin + for hash := 0 to hashtable_size-1 do begin + p := t[hash]; + while p <> nil do begin + p2 := thashitem(p.next); + linklistdel(tlinklist(t[hash]),tlinklist(p)); + p.destroy; + p := thashitem(p2); + end; + end; +end; + end.