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>farrealloc() adjust allocated block in far heap</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 farrealloc()            Adjust Allocated Block in Far Heap

 #include   <alloc.h>

 void far *farrealloc(block,newsize);
 void far *block;                        Allocated block in memory
 unsigned long newsize;                  New size of block

    farrealloc() changes the size of an allocated 'block' of memory in
    the far heap, changing its size to 'newsize'.  If necessary,
    farrealloc() also copies the block's contents to a new location.
    farrealloc() can reallocate memory from the far heap to include all
    of available RAM or reallocate blocks of memory larger than 64K.

       Returns:     The address of the reallocated block, which may not
                    be the same as the address of the original block.
                    NULL is returned if the block cannot be reallocated.

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

    The following statements allocate far memory, then resize it and then
    deallocate the memory.

           #include <alloc.h>      /* for farmalloc(), farfree() */
           #include <stdio.h>      /* for printf and NULL */

           main()
           {
               char far *buf;
               char far *temp;

               if ((buf = farmalloc(10000L)) == NULL)
                   printf("not enough memory to allocate");
               else {
                   /* try to make block larger */
                   if ((temp = farrealloc(buf,15000L)) == NULL)
                       printf("not enough memory to expand");
                   else {
                       buf = temp;
                       .
                       .
                  /* use allocated memory */
                  }
               farfree(buf);       /* deallocate memory */
               }
           }


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

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