home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume2 / pstrings / part01 / disposeS.p < prev    next >
Encoding:
Text File  |  1991-08-07  |  546 b   |  29 lines

  1.  
  2.  
  3.  
  4.  
  5. # include "strings.h"
  6.  
  7. procedure disposeS{(var s: String)};
  8. {
  9. * reclaims the storage associated with the string s
  10. }
  11.    var t, next: stringtail;
  12. begin
  13.   if s = nil then { -- Do nothing } else
  14.      if s^.REFS < 2 then begin { -- Only ref. to this string }
  15.     t := s^.TAIL;
  16.     dispose(s); s := nil; { -- emptyS }
  17.     while t <> nil do begin
  18.         next := t^.REST;
  19.         dispose(t);
  20.         t := next
  21.     end
  22.      end
  23.      else begin
  24.     { -- Decrement the references count, and make s = the empty string }
  25.     with s^ do REFS := REFS-1;
  26.     s := nil
  27.      end
  28. end{ -- disposeS};
  29.