home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 038 / pmd110.zip / TESTMEM.PAS < prev    next >
Pascal/Delphi Source File  |  1994-11-14  |  952b  |  53 lines

  1. {
  2.  
  3. Program to show application of MemCheck. Compile with debug info enabled
  4. if you want the InstallPMD to have any effect.
  5.  
  6. }
  7.  
  8.  
  9. {$X+}
  10. program TestMem;
  11.  
  12. uses {$IFDEF Windows}
  13.      WinCrt,
  14.      {$ENDIF}
  15.      BBError,
  16.      ObjMemory,
  17.      PMD, MemCheck;
  18.  
  19. var
  20.   p : pointer;
  21.   c : char;
  22.  
  23. procedure DisposeBug;
  24. begin
  25.   FreeMem(p, 200);
  26. end;
  27.  
  28. procedure OverwriteBug;
  29. begin
  30.   PChar(p)[100] := #0;
  31.   FreeMem(p, 100);
  32. end;
  33.  
  34.  
  35. begin
  36.   InitBBError('TESTMEM.LOG', TRUE);
  37.   InitObjMemory;
  38.   InitPMD(dfStandard);
  39.   GetMem(p, 100);
  40.   writeln('1. Dispose other size than allocated.');
  41.   writeln('2. Write into memory after allocated memory block.');
  42.   writeln('3. Allocated, but not deallocated -> see ', ReportFileName, '.');
  43.   writeln('X. Exit');
  44.   writeln;
  45.   write('Type 1, 2, 3 or X and press ENTER => ');
  46.   read(c);
  47.   case c of
  48.     '1' : DisposeBug;
  49.     '2' : OverwriteBug;
  50.     '3' : MemCheckReport;
  51.   end;
  52. end.
  53.