Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>the far package</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
The Far Package

   The Far package is a set of memory allocation functions that allow access
   to the far heap, these functions are direct hooks into DOS and are much

   slower than malloc, etc. They can also prevent the heap from expanding
   fully in S, M, T models, so you should not use _okbigbuf = 0 in your
   program.

   The advantages of these functions are that they give access to the whole
   of the available RAM in all memory models and memory blocks larger than
   64k can be allocated.

   It is necessary to use far pointers to access memory blocks allocated
   with the far... functions. Use huge pointers for blocks larger than 64k.

Example 

   #include <dos.h>
   #include <stdio.h>
   #include <stdlib.h>

   int main()
   {
   char far *memblock;
   long allocate = 65000;
       printf("%lu bytes memory free\n",farcoreleft());
       memblock = farmalloc(allocate);
       if(memblock == NULL) {
           printf("failed to allocate memory-block\n");
           exit(EXIT_FAILURE);
       }
       printf("%lu bytes allocated, ",allocate);
       printf("%lu bytes memory free\n",farcoreleft());
       allocate /= 2;
       memblock = farrealloc(memblock, allocate);
       printf("memory now reallocated to %lu bytes,",
                   allocate);
       printf("%lu bytes memory free\n",farcoreleft());
       farfree(memblock);
       printf("memory-block now freed, ");

       printf("%lu bytes memory free\n",farcoreleft());
       return EXIT_SUCCESS;
   }


See Also

   Functions with the prefix far. ns with the prefix far.





Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson