Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>farmalloc() allocate memory from far heap</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 farmalloc()             Allocate Memory from Far Heap

 #include   <alloc.h>

 void far       *farmalloc(size);
 unsigned long  size;                    Size of memory block

 farmalloc() allocates a block of memory from the far heap that is 'size'
 bytes long.  Allocations from the far heap can include all of available RAM.
 farmalloc() can allocate blocks of memory larger than 64K.   Use farfree()
 in the small and medium memory models to free blocks of memory allocated
 with farmalloc().

       Returns:     A far pointer to the newly allocated block, if
                    successful; NULL if there is not enough space for the
                    new block.

         Notes:     farmalloc() differs from malloc() in that it takes
                    unsigned long parameters; malloc() takes unsigned.

                    The tiny model cannot have any segment fixups (which
                    are often produced by far pointers), and thus cannot
                    use farmalloc().

   -------------------------------- Example ---------------------------------

    The following statements allocate space for 1000 bytes and then free
    the allocated space.

           #include <alloc.h>
           #include <stdio.h>      /* for printf and NULL */

           char far *far_ptr;

           main()
           {
               if ((far_ptr = farmalloc(1000L)) == NULL)
                    printf("not enough room to allocate memory\n");
               else {
                    .
                    .
                    farfree(far_ptr);
                }
            }


See Also: farcalloc() farcoreleft() farfree() farrealloc()

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