home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / tctnt / allocm2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-27  |  799 b   |  30 lines

  1. /* ALLOCM2.C: resolutions to allocation problems in ALLOCM1
  2. */
  3.  
  4. #include <alloc.h>            // for farmalloc()
  5. #include <dos.h>                // for allocmem()
  6. #include <stdio.h>            // for printf()
  7.  
  8. //*******************************************************************
  9. main()
  10. {
  11. #pragma warn -aus                // ptr IS assigned a value that isn't used!
  12.     unsigned seg, count = 0;
  13.     char far *ptr;
  14.  
  15.     _AX = 0x5801;
  16.     _BX = 2;
  17.     geninterrupt(0x21);    // set allocation strategy to last fit
  18.     allocmem( 100, &seg ); // grab highest block
  19.     _AX = 0x5801;
  20.     _BX = 0;
  21.     geninterrupt(0x21);    // reset allocation strategy
  22.     printf(" Allocated block at %X:0000\n", seg);
  23.     while ((ptr = (char far*) farmalloc(50)) != NULL)
  24.         count++;
  25.     printf(" Allocated %u 50 byte pieces\n", count);
  26.  
  27.     return 0;
  28. } // end of main()
  29.  
  30.