home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / dtx9202 / borhot / allocm2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-07  |  1.4 KB  |  40 lines

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