tb0240.pp 810 B

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