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++ Language Reference - far_package http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   Far_Package
   The  Far package are 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.


   Example
   #include <stdio.h>
   #include <dos.h>
   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(1);
        }
        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());
   }


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