home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXTST8F.ZIP / EMX / TEST / SHOWMEM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-28  |  1.1 KB  |  42 lines

  1. /* showmem.c (emx+gcc) */
  2.  
  3. #define INCL_DOSMEMMGR
  4. #include <os2.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8.  
  9. int main (void)
  10. {
  11.   ULONG rc, size, flags, base, esp;
  12.   char big[10000], *heap;
  13.  
  14.   heap = malloc (1);
  15.   big[0] = 0;
  16.   base = 0x10000;
  17.   esp = (ULONG)&esp;
  18.   for (;;)
  19.     {
  20.       size = 0xffffffff;
  21.       rc = DosQueryMem ((PVOID)base, &size, &flags);
  22.       if (rc != 0)
  23.         {
  24.           printf ("DosQueryMem failed, rc=%lu\n", rc);
  25.           return (1);
  26.         }
  27.       printf ("%.8lx - %.8lx (%.8lx)", base, base + size - 1, size);
  28.       if (flags & PAG_FREE)    printf (" FREE  ");
  29.       if (flags & PAG_COMMIT)  printf (" COMMIT");
  30.       if (flags & PAG_GUARD)   printf (" GUARD ");
  31.       if (flags & PAG_SHARED)  printf (" share ");
  32.       if (flags & PAG_READ)    printf (" read  ");
  33.       if (flags & PAG_READ)    printf (" write ");
  34.       if (flags & PAG_EXECUTE) printf (" exec  ");
  35.       if (base <= esp && esp < base + size) printf ("<-- ESP");
  36.       putchar ('\n');
  37.       base += size;
  38.       if (base == 0) break;
  39.     }
  40.   return (0);
  41. }
  42.