tb0240.pp 759 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. { Old file: tbs0280.pp }
  2. { problem with object finalization. OK 0.99.13 (FK) }
  3. {$mode objfpc}
  4. {$H+}
  5. program memhole;
  6. type
  7. TMyClass = class
  8. s: String;
  9. end;
  10. plongint = ^longint;
  11. procedure dotest;
  12. var
  13. c: TMyClass;
  14. s : string;
  15. begin
  16. s:='world';
  17. s:='Hallo '+s;
  18. writeln((plongint(s)-4)^);
  19. c := TMyClass.Create;
  20. writeln(longint(c.s));
  21. c.s := Copy('Test', 1, 4);
  22. writeln((plongint(c.s)-4)^);
  23. c.free;
  24. end;
  25. var
  26. membefore : longint;
  27. begin
  28. membefore:=memavail;
  29. writeln(memavail);
  30. dotest;
  31. writeln(memavail);
  32. if membefore<>memavail then
  33. begin
  34. Writeln('Memory hole using ansi strings in classes');
  35. Halt(1);
  36. end
  37. else
  38. Writeln('No memory hole unsing ansi strings in classes');
  39. end.